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 5from telemetry import value as value_module 6from telemetry.value import (improvement_direction 7 as improvement_direction_module) 8 9 10class SummarizableValue(value_module.Value): 11 def __init__(self, page, name, units, important, description, tir_label, 12 improvement_direction, grouping_keys): 13 """A summarizable value result from a test.""" 14 super(SummarizableValue, self).__init__( 15 page, name, units, important, description, tir_label, grouping_keys) 16# TODO(eakuefner): uncomment this assert after Telemetry clients are fixed. 17# Note: Telemetry unittests satisfy this assert. 18# assert improvement_direction_module.IsValid(improvement_direction) 19 self._improvement_direction = improvement_direction 20 21 @property 22 def improvement_direction(self): 23 return self._improvement_direction 24 25 def AsDict(self): 26 d = super(SummarizableValue, self).AsDict() 27 if improvement_direction_module.IsValid(self.improvement_direction): 28 d['improvement_direction'] = self.improvement_direction 29 return d 30 31 @staticmethod 32 def GetJSONTypeName(): 33 return 'summarizable' 34 35 def AsDictWithoutBaseClassEntries(self): 36 d = super(SummarizableValue, self).AsDictWithoutBaseClassEntries() 37 if 'improvement_direction' in d: 38 del d['improvement_direction'] 39 return d 40 41 def GetBuildbotDataType(self, output_context): 42 """Returns the buildbot's equivalent data_type. 43 44 This should be one of the values accepted by perf_tests_results_helper.py. 45 """ 46 raise NotImplementedError() 47 48 def GetBuildbotValue(self): 49 """Returns the buildbot's equivalent value.""" 50 raise NotImplementedError() 51 52 @classmethod 53 def MergeLikeValuesFromSamePage(cls, values): 54 raise NotImplementedError() 55 56 @classmethod 57 def MergeLikeValuesFromDifferentPages(cls, values): 58 raise NotImplementedError() 59 60 def GetRepresentativeNumber(self): 61 """Gets a single scalar value that best-represents this value. 62 63 Returns None if not possible. 64 """ 65 raise NotImplementedError() 66 67 def GetRepresentativeString(self): 68 """Gets a string value that best-represents this value. 69 70 Returns None if not possible. 71 """ 72 raise NotImplementedError() 73