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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/perf_tools/histogram_measurement.py
diff --git a/tools/perf/perf_tools/histogram_measurement.py b/tools/perf/perf_tools/histogram_measurement.py
new file mode 100644
index 0000000000000000000000000000000000000000..0cdbd0eb51c33b67602d7eb5ab19a61673624d02
--- /dev/null
+++ b/tools/perf/perf_tools/histogram_measurement.py
@@ -0,0 +1,42 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+from perf_tools import histogram as histogram_module
+
+BROWSER_HISTOGRAM = 'browser_histogram'
+RENDERER_HISTOGRAM = 'renderer_histogram'
+
+class HistogramMeasurement(object):
+ def __init__(self, histogram, histogram_type):
+ self.name = histogram['name']
+ self.units = histogram['units']
+ self.histogram_type = histogram_type
+ self._start_values = dict()
+
+ def Start(self, page, tab):
+ """Get the starting value for the histogram. This value will then be
+ subtracted from the actual measurement."""
+ data = self._GetHistogramFromDomAutomation(tab)
+ if data:
+ self._start_values[page.url + self.name] = data
+
+ def GetValue(self, page, tab, results):
+ data = self._GetHistogramFromDomAutomation(tab)
+ if not data:
+ return
+ new_histogram = histogram_module.SubtractHistogram(
+ data, self._start_values[page.url + self.name])
+ results.Add(self.name.replace('.', '_'), self.units,
+ new_histogram, data_type='histogram')
+
+ @property
+ def histogram_function(self):
+ if self.histogram_type == BROWSER_HISTOGRAM:
+ return 'getBrowserHistogram'
+ return 'getHistogram'
+
+ def _GetHistogramFromDomAutomation(self, tab):
+ js = ('window.domAutomationController.%s ? '
+ 'window.domAutomationController.%s("%s") : ""' %
+ (self.histogram_function, self.histogram_function, self.name))
+ return tab.EvaluateJavaScript(js)
« 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