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

Side by Side Diff: tools/perf/perf_tools/histogram_measurement.py

Issue 12221137: Telemetry / Memory benchmark fix: Separate histograms for different tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add error msg if we do nonsensemaking histogram stuff Created 7 years, 10 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
« no previous file with comments | « tools/perf/perf_tools/histogram.py ('k') | tools/perf/perf_tools/histogram_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2013 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 from perf_tools import histogram as histogram_module
5
6 BROWSER_HISTOGRAM = 'browser_histogram'
7 RENDERER_HISTOGRAM = 'renderer_histogram'
8
9 class HistogramMeasurement(object):
10 def __init__(self, histogram, histogram_type):
11 self.name = histogram['name']
12 self.units = histogram['units']
13 self.histogram_type = histogram_type
14 self._start_values = dict()
15
16 def Start(self, page, tab):
17 """Get the starting value for the histogram. This value will then be
18 subtracted from the actual measurement."""
19 data = self._GetHistogramFromDomAutomation(tab)
20 if data:
21 self._start_values[page.url + self.name] = data
22
23 def GetValue(self, page, tab, results):
24 data = self._GetHistogramFromDomAutomation(tab)
25 if not data:
26 return
27 new_histogram = histogram_module.SubtractHistogram(
28 data, self._start_values[page.url + self.name])
29 results.Add(self.name.replace('.', '_'), self.units,
30 new_histogram, data_type='histogram')
31
32 @property
33 def histogram_function(self):
34 if self.histogram_type == BROWSER_HISTOGRAM:
35 return 'getBrowserHistogram'
36 return 'getHistogram'
37
38 def _GetHistogramFromDomAutomation(self, tab):
39 js = ('window.domAutomationController.%s ? '
40 'window.domAutomationController.%s("%s") : ""' %
41 (self.histogram_function, self.histogram_function, self.name))
42 return tab.EvaluateJavaScript(js)
OLDNEW
« no previous file with comments | « tools/perf/perf_tools/histogram.py ('k') | tools/perf/perf_tools/histogram_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698