OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 import json | 4 import json |
5 | 5 |
6 from telemetry import value as value_module | 6 from telemetry import value as value_module |
7 from telemetry import perf_tests_helper | 7 from telemetry import perf_tests_helper |
8 | 8 |
9 | 9 |
10 class HistogramValueBucket(object): | 10 class HistogramValueBucket(object): |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 def ToJSONString(self): | 23 def ToJSONString(self): |
24 return '{%s}' % ', '.join([ | 24 return '{%s}' % ', '.join([ |
25 '"low": %i' % self.low, | 25 '"low": %i' % self.low, |
26 '"high": %i' % self.high, | 26 '"high": %i' % self.high, |
27 '"count": %i' % self.count]) | 27 '"count": %i' % self.count]) |
28 | 28 |
29 class HistogramValue(value_module.Value): | 29 class HistogramValue(value_module.Value): |
30 def __init__(self, page, name, units, | 30 def __init__(self, page, name, units, |
31 raw_value=None, raw_value_json=None, important=True, | 31 raw_value=None, raw_value_json=None, important=True, |
32 description=None): | 32 description=None, paths=None): |
33 super(HistogramValue, self).__init__(page, name, units, important, | 33 super(HistogramValue, self).__init__(page, name, units, important, |
34 description) | 34 description, paths) |
35 if raw_value_json: | 35 if raw_value_json: |
36 assert raw_value == None, \ | 36 assert raw_value == None, \ |
37 'Don\'t specify both raw_value and raw_value_json' | 37 'Don\'t specify both raw_value and raw_value_json' |
38 raw_value = json.loads(raw_value_json) | 38 raw_value = json.loads(raw_value_json) |
39 if raw_value: | 39 if raw_value: |
40 assert 'buckets' in raw_value | 40 assert 'buckets' in raw_value |
41 assert isinstance(raw_value['buckets'], list) | 41 assert isinstance(raw_value['buckets'], list) |
42 self.buckets = [] | 42 self.buckets = [] |
43 for bucket in raw_value['buckets']: | 43 for bucket in raw_value['buckets']: |
44 self.buckets.append(HistogramValueBucket( | 44 self.buckets.append(HistogramValueBucket( |
45 low=bucket['low'], | 45 low=bucket['low'], |
46 high=bucket['high'], | 46 high=bucket['high'], |
47 count=bucket['count'])) | 47 count=bucket['count'])) |
48 else: | 48 else: |
49 self.buckets = [] | 49 self.buckets = [] |
50 | 50 |
51 def __repr__(self): | 51 def __repr__(self): |
52 if self.page: | 52 if self.page: |
53 page_name = self.page.url | 53 page_name = self.page.url |
54 else: | 54 else: |
55 page_name = None | 55 page_name = None |
56 return ('HistogramValue(%s, %s, %s, raw_json_string="%s", ' | 56 return ('HistogramValue(%s, %s, %s, raw_json_string="%s", ' |
57 'important=%s, description=%s') % ( | 57 'important=%s, description=%s, paths=%s') % ( |
58 page_name, | 58 page_name, |
59 self.name, self.units, | 59 self.name, self.units, |
60 self.ToJSONString(), | 60 self.ToJSONString(), |
61 self.important, | 61 self.important, |
62 self.description) | 62 self.description, |
| 63 self.paths) |
63 | 64 |
64 def GetBuildbotDataType(self, output_context): | 65 def GetBuildbotDataType(self, output_context): |
65 if self._IsImportantGivenOutputIntent(output_context): | 66 if self._IsImportantGivenOutputIntent(output_context): |
66 return 'histogram' | 67 return 'histogram' |
67 return 'unimportant-histogram' | 68 return 'unimportant-histogram' |
68 | 69 |
69 def GetBuildbotValue(self): | 70 def GetBuildbotValue(self): |
70 # More buildbot insanity: perf_tests_results_helper requires the histogram | 71 # More buildbot insanity: perf_tests_results_helper requires the histogram |
71 # to be an array of size one. | 72 # to be an array of size one. |
72 return [self.ToJSONString()] | 73 return [self.ToJSONString()] |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 important=v0.important) | 118 important=v0.important) |
118 | 119 |
119 @classmethod | 120 @classmethod |
120 def MergeLikeValuesFromDifferentPages(cls, values, | 121 def MergeLikeValuesFromDifferentPages(cls, values, |
121 group_by_name_suffix=False): | 122 group_by_name_suffix=False): |
122 # Histograms cannot be merged across pages, at least for now. It should be | 123 # Histograms cannot be merged across pages, at least for now. It should be |
123 # theoretically possible, just requires more work. Instead, return None. | 124 # theoretically possible, just requires more work. Instead, return None. |
124 # This signals to the merging code that the data is unmergable and it will | 125 # This signals to the merging code that the data is unmergable and it will |
125 # cope accordingly. | 126 # cope accordingly. |
126 return None | 127 return None |
OLD | NEW |