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

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

Issue 22492004: Move memory-related histogram data collection to metrics/memory.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor change (to make what is happening more explicit) 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
« no previous file with comments | « no previous file | tools/perf/metrics/memory.py » ('j') | tools/perf/metrics/memory.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
5 """This is a helper module to get and manipulate histogram data. 5 """This is a helper module to get and manipulate histogram data.
6 6
7 The histogram data is the same data as is visible from "chrome://histograms". 7 The histogram data is the same data as is visible from "chrome://histograms".
8 More information can be found at: chromium/src/base/metrics/histogram.h 8 More information can be found at: chromium/src/base/metrics/histogram.h
9 9
10 Histogram data is collected with either the window.statsCollectionController 10 Histogram data is collected with either the window.statsCollectionController
11 object or the window.domAutomationController object. 11 object or the window.domAutomationController object.
12 """ 12 """
13 13
14 import json 14 import json
15 import logging 15 import logging
16 16
17 BROWSER_HISTOGRAM = 'browser_histogram' 17 BROWSER_HISTOGRAM = 'browser_histogram'
18 RENDERER_HISTOGRAM = 'renderer_histogram' 18 RENDERER_HISTOGRAM = 'renderer_histogram'
19 19
20 def GetHistogramData(histogram_type, histogram_name, tab): 20 def GetHistogramData(histogram_type, histogram_name, tab):
21 """Get a json serialization of a histogram.""" 21 """Get a json serialization of a histogram."""
22 assert histogram_type in [BROWSER_HISTOGRAM, RENDERER_HISTOGRAM] 22 assert histogram_type in [BROWSER_HISTOGRAM, RENDERER_HISTOGRAM]
23 function = 'getHistogram' 23 function = 'getHistogram'
24 if histogram_type == BROWSER_HISTOGRAM: 24 if histogram_type == BROWSER_HISTOGRAM:
25 function = 'getBrowserHistogram' 25 function = 'getBrowserHistogram'
26 # TODO(jeremy): Remove references to 26 # TODO(jeremy): Remove references to
27 # domAutomationController when we update the reference builds. 27 # domAutomationController when we update the reference builds.
28 return tab.EvaluateJavaScript( 28 histogram_json = tab.EvaluateJavaScript(
29 '(window.statsCollectionController ? ' 29 '(window.statsCollectionController ? '
30 'statsCollectionController : ' 30 'statsCollectionController : '
31 'domAutomationController).%s("%s")' % 31 'domAutomationController).%s("%s")' %
32 (function, histogram_name)) 32 (function, histogram_name))
33 33 if histogram_json:
34 return histogram_json
35 return None
34 36
35 def SubtractHistogram(histogram_json, start_histogram_json): 37 def SubtractHistogram(histogram_json, start_histogram_json):
36 """Subtracts a previous histogram from a histogram. 38 """Subtracts a previous histogram from a histogram.
37 39
38 Both parameters and the returned result are json serializations. 40 Both parameters and the returned result are json serializations.
39 """ 41 """
40 start_histogram = json.loads(start_histogram_json) 42 start_histogram = json.loads(start_histogram_json)
41 # It's ok if the start histogram is empty (we had no data, maybe even no 43 # It's ok if the start histogram is empty (we had no data, maybe even no
42 # histogram at all, at the start of the test). 44 # histogram at all, at the start of the test).
43 if 'buckets' not in start_histogram: 45 if 'buckets' not in start_histogram:
(...skipping 19 matching lines...) Expand all
63 if new_bucket['count'] < 0: 65 if new_bucket['count'] < 0:
64 logging.error('Histogram subtraction error, starting histogram most ' 66 logging.error('Histogram subtraction error, starting histogram most '
65 'probably invalid.') 67 'probably invalid.')
66 if new_bucket['count']: 68 if new_bucket['count']:
67 new_buckets.append(new_bucket) 69 new_buckets.append(new_bucket)
68 histogram['buckets'] = new_buckets 70 histogram['buckets'] = new_buckets
69 histogram['count'] -= start_histogram['count'] 71 histogram['count'] -= start_histogram['count']
70 72
71 return json.dumps(histogram) 73 return json.dumps(histogram)
72 74
OLDNEW
« no previous file with comments | « no previous file | tools/perf/metrics/memory.py » ('j') | tools/perf/metrics/memory.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698