Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from telemetry import value as value_module | |
| 6 from telemetry.value import improvement_direction as improvement_direction_modul e | |
|
qyearsley
2015/01/27 00:50:46
Just barely over 80 columns :-/ If linter doesn't
| |
| 7 | |
| 8 | |
| 9 class SummarizableValue(value_module.Value): | |
| 10 def __init__(self, page, name, units, important, description, | |
| 11 improvement_direction): | |
| 12 """A summarizable value result from a test.""" | |
| 13 super(SummarizableValue, self).__init__( | |
| 14 page, name, units, important, description) | |
| 15 assert improvement_direction_module.IsValid(improvement_direction) | |
| 16 self._improvement_direction = improvement_direction | |
| 17 | |
| 18 @property | |
| 19 def improvement_direction(self): | |
| 20 return self._improvement_direction | |
| 21 | |
| 22 def AsDict(self): | |
| 23 d = super(SummarizableValue, self).AsDict() | |
| 24 d['improvement_direction'] = self.improvement_direction | |
| 25 return d | |
| 26 | |
| 27 @staticmethod | |
| 28 def GetJSONTypeName(): | |
| 29 return 'summarizable' | |
| 30 | |
| 31 def AsDictWithoutBaseClassEntries(self): | |
| 32 d = super(SummarizableValue, self).AsDictWithoutBaseClassEntries() | |
| 33 del d['improvement_direction'] | |
| 34 return d | |
| 35 | |
| 36 def GetBuildbotDataType(self, output_context): | |
| 37 """Returns the buildbot's equivalent data_type. | |
| 38 | |
| 39 This should be one of the values accepted by perf_tests_results_helper.py. | |
| 40 """ | |
| 41 raise NotImplementedError() | |
| 42 | |
| 43 def GetBuildbotValue(self): | |
| 44 """Returns the buildbot's equivalent value.""" | |
| 45 raise NotImplementedError() | |
| 46 | |
| 47 @classmethod | |
| 48 def MergeLikeValuesFromSamePage(cls, values): | |
| 49 """Combines the provided list of values into a single compound value. | |
| 50 | |
| 51 When a page runs multiple times, it may produce multiple values. This | |
| 52 function is given the same-named values across the multiple runs, and has | |
| 53 the responsibility of producing a single result. | |
| 54 | |
| 55 It must return a single Value. If merging does not make sense, the | |
| 56 implementation must pick a representative value from one of the runs. | |
| 57 | |
| 58 For instance, it may be given | |
| 59 [ScalarValue(page, 'a', 1), ScalarValue(page, 'a', 2)] | |
| 60 and it might produce | |
| 61 ListOfScalarValues(page, 'a', [1, 2]) | |
| 62 """ | |
| 63 raise NotImplementedError() | |
| 64 | |
| 65 @classmethod | |
| 66 def MergeLikeValuesFromDifferentPages(cls, values, | |
| 67 group_by_name_suffix=False): | |
| 68 """Combines the provided values into a single compound value. | |
| 69 | |
| 70 When a full pageset runs, a single value_name will usually end up getting | |
| 71 collected for multiple pages. For instance, we may end up with | |
| 72 [ScalarValue(page1, 'a', 1), | |
| 73 ScalarValue(page2, 'a', 2)] | |
| 74 | |
| 75 This function takes in the values of the same name, but across multiple | |
| 76 pages, and produces a single summary result value. In this instance, it | |
| 77 could produce a ScalarValue(None, 'a', 1.5) to indicate averaging, or even | |
| 78 ListOfScalarValues(None, 'a', [1, 2]) if concatenated output was desired. | |
| 79 | |
| 80 Some results are so specific to a page that they make no sense when | |
| 81 aggregated across pages. If merging values of this type across pages is | |
| 82 non-sensical, this method may return None. | |
| 83 | |
| 84 If group_by_name_suffix is True, then x.z and y.z are considered to be the | |
| 85 same value and are grouped together. If false, then x.z and y.z are | |
| 86 considered different. | |
| 87 """ | |
| 88 raise NotImplementedError() | |
| 89 | |
| 90 def GetRepresentativeNumber(self): | |
| 91 """Gets a single scalar value that best-represents this value. | |
| 92 | |
| 93 Returns None if not possible. | |
| 94 """ | |
| 95 raise NotImplementedError() | |
| 96 | |
| 97 def GetRepresentativeString(self): | |
| 98 """Gets a string value that best-represents this value. | |
| 99 | |
| 100 Returns None if not possible. | |
| 101 """ | |
| 102 raise NotImplementedError() | |
| OLD | NEW |