Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(661)

Side by Side Diff: tools/telemetry/telemetry/value/__init__.py

Issue 545523002: [Telemetry] Add capability for values to reference external files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better approach + more tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 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 """ 4 """
5 The Value hierarchy provides a way of representing the values measurements 5 The Value hierarchy provides a way of representing the values measurements
6 produce such that they can be merged across runs, grouped by page, and output 6 produce such that they can be merged across runs, grouped by page, and output
7 to different targets. 7 to different targets.
8 8
9 The core Value concept provides the basic functionality: 9 The core Value concept provides the basic functionality:
10 - association with a page, may be none 10 - association with a page, may be none
(...skipping 24 matching lines...) Expand all
35 # value is being interpreted actually affects the conversion. This is insane, 35 # value is being interpreted actually affects the conversion. This is insane,
36 # but there you have it. There are three contexts in which Values are converted 36 # but there you have it. There are three contexts in which Values are converted
37 # for use by buildbot, represented by these output-intent values. 37 # for use by buildbot, represented by these output-intent values.
38 PER_PAGE_RESULT_OUTPUT_CONTEXT = 'per-page-result-output-context' 38 PER_PAGE_RESULT_OUTPUT_CONTEXT = 'per-page-result-output-context'
39 COMPUTED_PER_PAGE_SUMMARY_OUTPUT_CONTEXT = 'merged-pages-result-output-context' 39 COMPUTED_PER_PAGE_SUMMARY_OUTPUT_CONTEXT = 'merged-pages-result-output-context'
40 SUMMARY_RESULT_OUTPUT_CONTEXT = 'summary-result-output-context' 40 SUMMARY_RESULT_OUTPUT_CONTEXT = 'summary-result-output-context'
41 41
42 class Value(object): 42 class Value(object):
43 """An abstract value produced by a telemetry page test. 43 """An abstract value produced by a telemetry page test.
44 """ 44 """
45 def __init__(self, page, name, units, important, description): 45 def __init__(self, page, name, units, important, description, paths):
46 """A generic Value object. 46 """A generic Value object.
47 47
48 Args: 48 Args:
49 page: A Page object, may be given as None to indicate that the value 49 page: A Page object, may be given as None to indicate that the value
50 represents results for multiple pages. 50 represents results for multiple pages.
51 name: A value name string, may contain a dot. Values from the same test 51 name: A value name string, may contain a dot. Values from the same test
52 with the same prefix before the dot may be considered to belong to 52 with the same prefix before the dot may be considered to belong to
53 the same chart. 53 the same chart.
54 units: A units string. 54 units: A units string.
55 important: Whether the value is "important". Causes the value to appear 55 important: Whether the value is "important". Causes the value to appear
56 by default in downstream UIs. 56 by default in downstream UIs.
57 description: A string explaining in human-understandable terms what this 57 description: A string explaining in human-understandable terms what this
58 value represents. 58 value represents.
59 paths: A list of paths corresponding to files associated with this value.
nednguyen 2014/09/08 18:45:24 What are paths? Are they strings, or are they inst
59 """ 60 """
60 self.page = page 61 self.page = page
61 self.name = name 62 self.name = name
62 self.units = units 63 self.units = units
63 self.important = important 64 self.important = important
64 self.description = description 65 self.description = description
66 if paths is None:
67 self.paths = []
68 else:
69 self.paths = paths
65 70
66 def IsMergableWith(self, that): 71 def IsMergableWith(self, that):
67 return (self.units == that.units and 72 return (self.units == that.units and
68 type(self) == type(that) and 73 type(self) == type(that) and
69 self.important == that.important) 74 self.important == that.important)
70 75
71 @classmethod 76 @classmethod
72 def MergeLikeValuesFromSamePage(cls, values): 77 def MergeLikeValuesFromSamePage(cls, values):
73 """Combines the provided list of values into a single compound value. 78 """Combines the provided list of values into a single compound value.
74 79
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 d = { 183 d = {
179 'name': self.name, 184 'name': self.name,
180 'type': self.GetJSONTypeName(), 185 'type': self.GetJSONTypeName(),
181 'units': self.units, 186 'units': self.units,
182 } 187 }
183 188
184 if self.description: 189 if self.description:
185 d['description'] = self.description 190 d['description'] = self.description
186 191
187 if self.page: 192 if self.page:
188 d['page_id'] = self.page.id 193 d['page_id'] = self.page.id
nduca 2014/09/08 18:53:02 How about ""Returns file handle... or none."""
189 194
195 if self.paths:
196 # Assigning IDs to paths is a serialization detail, so we defer updating
197 # this to an ID until we actually intend on serializing this value.
198 d['paths'] = self.paths
199
190 return d 200 return d
191 201
192 def AsDictWithoutBaseClassEntries(self): 202 def AsDictWithoutBaseClassEntries(self):
193 full_dict = self.AsDict() 203 full_dict = self.AsDict()
194 base_dict_keys = set(self._AsDictImpl().keys()) 204 base_dict_keys = set(self._AsDictImpl().keys())
195 205
196 # Extracts only entries added by the subclass. 206 # Extracts only entries added by the subclass.
197 return dict([(k, v) for (k, v) in full_dict.iteritems() 207 return dict([(k, v) for (k, v) in full_dict.iteritems()
198 if k not in base_dict_keys]) 208 if k not in base_dict_keys])
199 209
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 whereas telemetry represents values with a chart_name.trace_name convention, 307 whereas telemetry represents values with a chart_name.trace_name convention,
298 where chart_name is optional. This convention is also used by chart_json. 308 where chart_name is optional. This convention is also used by chart_json.
299 309
300 This converts from the telemetry convention to the buildbot convention, 310 This converts from the telemetry convention to the buildbot convention,
301 returning a 2-tuple (measurement_name, trace_name). 311 returning a 2-tuple (measurement_name, trace_name).
302 """ 312 """
303 if '.' in value_name: 313 if '.' in value_name:
304 return value_name.split('.', 1) 314 return value_name.split('.', 1)
305 else: 315 else:
306 return value_name, value_name 316 return value_name, value_name
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698