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

Side by Side Diff: tools/perf/metrics/histogram.py

Issue 22754003: Refactor BenchmarkResult.Add to take enum for data_type (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
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
4 from metrics import histogram_util 5 from metrics import histogram_util
6 from telemetry.page import result_data_type
5 7
6 BROWSER_HISTOGRAM = 'browser_histogram' 8 BROWSER_HISTOGRAM = 'browser_histogram'
7 RENDERER_HISTOGRAM = 'renderer_histogram' 9 RENDERER_HISTOGRAM = 'renderer_histogram'
8 10
9 class HistogramMetric(object): 11 class HistogramMetric(object):
10 def __init__(self, histogram, histogram_type): 12 def __init__(self, histogram, histogram_type):
11 self.name = histogram['name'] 13 self.name = histogram['name']
12 self.units = histogram['units'] 14 self.units = histogram['units']
13 self.histogram_type = histogram_type 15 self.histogram_type = histogram_type
14 self._start_values = dict() 16 self._start_values = dict()
15 17
16 def Start(self, page, tab): 18 def Start(self, page, tab):
17 """Get the starting value for the histogram. This value will then be 19 """Get the starting value for the histogram. This value will then be
18 subtracted from the actual measurement.""" 20 subtracted from the actual measurement."""
19 data = self._GetHistogramFromDomAutomation(tab) 21 data = self._GetHistogramFromDomAutomation(tab)
20 if data: 22 if data:
21 self._start_values[page.url + self.name] = data 23 self._start_values[page.url + self.name] = data
22 24
23 def GetValue(self, page, tab, results): 25 def GetValue(self, page, tab, results):
24 data = self._GetHistogramFromDomAutomation(tab) 26 data = self._GetHistogramFromDomAutomation(tab)
25 if not data: 27 if not data:
26 return 28 return
27 new_histogram = histogram_util.SubtractHistogram( 29 new_histogram = histogram_util.SubtractHistogram(
28 data, self._start_values[page.url + self.name]) 30 data, self._start_values[page.url + self.name])
29 results.Add(self.name, self.units, new_histogram, 31 results.Add(self.name, self.units, new_histogram,
30 data_type='unimportant-histogram') 32 data_type=result_data_type.UNIMPORTANT_HISTOGRAM)
31 33
32 @property 34 @property
33 def histogram_function(self): 35 def histogram_function(self):
34 if self.histogram_type == BROWSER_HISTOGRAM: 36 if self.histogram_type == BROWSER_HISTOGRAM:
35 return 'getBrowserHistogram' 37 return 'getBrowserHistogram'
36 return 'getHistogram' 38 return 'getHistogram'
37 39
38 def _GetHistogramFromDomAutomation(self, tab): 40 def _GetHistogramFromDomAutomation(self, tab):
39 return histogram_util.GetHistogramFromDomAutomation( 41 return histogram_util.GetHistogramFromDomAutomation(
40 self.histogram_function, self.name, tab) 42 self.histogram_function, self.name, tab)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698