Chromium Code Reviews| Index: tools/telemetry/telemetry/value/summarizable.py |
| diff --git a/tools/telemetry/telemetry/value/summarizable.py b/tools/telemetry/telemetry/value/summarizable.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2bbfd5347fea39ca4ce255ca5dd5437945355d27 |
| --- /dev/null |
| +++ b/tools/telemetry/telemetry/value/summarizable.py |
| @@ -0,0 +1,102 @@ |
| +# Copyright 2014 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +from telemetry import value as value_module |
| +from telemetry.value import improvement_direction as improvement_direction_module |
|
qyearsley
2015/01/27 00:50:46
Just barely over 80 columns :-/ If linter doesn't
|
| + |
| + |
| +class SummarizableValue(value_module.Value): |
| + def __init__(self, page, name, units, important, description, |
| + improvement_direction): |
| + """A summarizable value result from a test.""" |
| + super(SummarizableValue, self).__init__( |
| + page, name, units, important, description) |
| + assert improvement_direction_module.IsValid(improvement_direction) |
| + self._improvement_direction = improvement_direction |
| + |
| + @property |
| + def improvement_direction(self): |
| + return self._improvement_direction |
| + |
| + def AsDict(self): |
| + d = super(SummarizableValue, self).AsDict() |
| + d['improvement_direction'] = self.improvement_direction |
| + return d |
| + |
| + @staticmethod |
| + def GetJSONTypeName(): |
| + return 'summarizable' |
| + |
| + def AsDictWithoutBaseClassEntries(self): |
| + d = super(SummarizableValue, self).AsDictWithoutBaseClassEntries() |
| + del d['improvement_direction'] |
| + return d |
| + |
| + def GetBuildbotDataType(self, output_context): |
| + """Returns the buildbot's equivalent data_type. |
| + |
| + This should be one of the values accepted by perf_tests_results_helper.py. |
| + """ |
| + raise NotImplementedError() |
| + |
| + def GetBuildbotValue(self): |
| + """Returns the buildbot's equivalent value.""" |
| + raise NotImplementedError() |
| + |
| + @classmethod |
| + def MergeLikeValuesFromSamePage(cls, values): |
| + """Combines the provided list of values into a single compound value. |
| + |
| + When a page runs multiple times, it may produce multiple values. This |
| + function is given the same-named values across the multiple runs, and has |
| + the responsibility of producing a single result. |
| + |
| + It must return a single Value. If merging does not make sense, the |
| + implementation must pick a representative value from one of the runs. |
| + |
| + For instance, it may be given |
| + [ScalarValue(page, 'a', 1), ScalarValue(page, 'a', 2)] |
| + and it might produce |
| + ListOfScalarValues(page, 'a', [1, 2]) |
| + """ |
| + raise NotImplementedError() |
| + |
| + @classmethod |
| + def MergeLikeValuesFromDifferentPages(cls, values, |
| + group_by_name_suffix=False): |
| + """Combines the provided values into a single compound value. |
| + |
| + When a full pageset runs, a single value_name will usually end up getting |
| + collected for multiple pages. For instance, we may end up with |
| + [ScalarValue(page1, 'a', 1), |
| + ScalarValue(page2, 'a', 2)] |
| + |
| + This function takes in the values of the same name, but across multiple |
| + pages, and produces a single summary result value. In this instance, it |
| + could produce a ScalarValue(None, 'a', 1.5) to indicate averaging, or even |
| + ListOfScalarValues(None, 'a', [1, 2]) if concatenated output was desired. |
| + |
| + Some results are so specific to a page that they make no sense when |
| + aggregated across pages. If merging values of this type across pages is |
| + non-sensical, this method may return None. |
| + |
| + If group_by_name_suffix is True, then x.z and y.z are considered to be the |
| + same value and are grouped together. If false, then x.z and y.z are |
| + considered different. |
| + """ |
| + raise NotImplementedError() |
| + |
| + def GetRepresentativeNumber(self): |
| + """Gets a single scalar value that best-represents this value. |
| + |
| + Returns None if not possible. |
| + """ |
| + raise NotImplementedError() |
| + |
| + def GetRepresentativeString(self): |
| + """Gets a string value that best-represents this value. |
| + |
| + Returns None if not possible. |
| + """ |
| + raise NotImplementedError() |