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

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

Issue 440323002: [Telemetry] Allow page cycler to run on devices that don't report CommitCharge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | no next file » | no next file with comments »
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 import sys 5 import sys
6 6
7 from metrics import histogram_util 7 from metrics import histogram_util
8 from metrics import Metric 8 from metrics import Metric
9 from telemetry.value import histogram 9 from telemetry.value import histogram
10 from telemetry.value import scalar 10 from telemetry.value import scalar
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 class MemoryMetric(Metric): 52 class MemoryMetric(Metric):
53 """MemoryMetric gathers memory statistics from the browser object. 53 """MemoryMetric gathers memory statistics from the browser object.
54 54
55 This includes both per-page histogram stats, most about javascript 55 This includes both per-page histogram stats, most about javascript
56 memory usage, and overall memory stats from the system for the whole 56 memory usage, and overall memory stats from the system for the whole
57 test run.""" 57 test run."""
58 58
59 def __init__(self, browser): 59 def __init__(self, browser):
60 super(MemoryMetric, self).__init__() 60 super(MemoryMetric, self).__init__()
61 self._browser = browser 61 self._browser = browser
62 self._start_commit_charge = self._browser.memory_stats['SystemCommitCharge'] 62 start_memory_stats = self._browser.memory_stats
63 self._start_commit_charge = None
64 if 'SystemCommitCharge' in start_memory_stats:
65 self._start_commit_charge = start_memory_stats['SystemCommitCharge']
63 self._memory_stats = None 66 self._memory_stats = None
64 self._histogram_start = dict() 67 self._histogram_start = dict()
65 self._histogram_delta = dict() 68 self._histogram_delta = dict()
66 69
67 @classmethod 70 @classmethod
68 def CustomizeBrowserOptions(cls, options): 71 def CustomizeBrowserOptions(cls, options):
69 options.AppendExtraBrowserArgs([ 72 options.AppendExtraBrowserArgs([
70 '--enable-stats-collection-bindings', 73 '--enable-stats-collection-bindings',
71 # For a hard-coded set of Google pages (such as GMail), we produce 74 # For a hard-coded set of Google pages (such as GMail), we produce
72 # custom memory histograms (V8.Something_gmail) instead of the generic 75 # custom memory histograms (V8.Something_gmail) instead of the generic
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 results.AddValue(histogram.HistogramValue( 121 results.AddValue(histogram.HistogramValue(
119 results.current_page, h['display_name'], h['units'], 122 results.current_page, h['display_name'], h['units'],
120 raw_value_json=self._histogram_delta[h['name']], important=False, 123 raw_value_json=self._histogram_delta[h['name']], important=False,
121 description=h.get('description'))) 124 description=h.get('description')))
122 self._memory_stats = self._browser.memory_stats 125 self._memory_stats = self._browser.memory_stats
123 if not self._memory_stats['Browser']: 126 if not self._memory_stats['Browser']:
124 return 127 return
125 AddResultsForProcesses(results, self._memory_stats, 128 AddResultsForProcesses(results, self._memory_stats,
126 metric_trace_name=trace_name) 129 metric_trace_name=trace_name)
127 130
128 end_commit_charge = self._memory_stats['SystemCommitCharge'] 131 if self._start_commit_charge:
129 commit_charge_difference = end_commit_charge - self._start_commit_charge 132 end_commit_charge = self._memory_stats['SystemCommitCharge']
130 results.AddValue(scalar.ScalarValue( 133 commit_charge_difference = end_commit_charge - self._start_commit_charge
131 results.current_page, 134 results.AddValue(scalar.ScalarValue(
132 'commit_charge.' + (trace_name or 'commit_charge'), 135 results.current_page,
133 'kb', commit_charge_difference, important=False, 136 'commit_charge.' + (trace_name or 'commit_charge'),
134 description='System commit charge (committed memory pages).')) 137 'kb', commit_charge_difference, important=False,
138 description='System commit charge (committed memory pages).'))
135 results.AddValue(scalar.ScalarValue( 139 results.AddValue(scalar.ScalarValue(
136 results.current_page, 'processes.' + (trace_name or 'processes'), 140 results.current_page, 'processes.' + (trace_name or 'processes'),
137 'count', self._memory_stats['ProcessCount'], important=False, 141 'count', self._memory_stats['ProcessCount'], important=False,
138 description='Number of processes used by Chrome.')) 142 description='Number of processes used by Chrome.'))
139 143
140 144
141 def AddResultsForProcesses(results, memory_stats, chart_trace_name='final', 145 def AddResultsForProcesses(results, memory_stats, chart_trace_name='final',
142 metric_trace_name=None, 146 metric_trace_name=None,
143 exclude_metrics=None): 147 exclude_metrics=None):
144 """Adds memory stats for browser, renderer and gpu processes. 148 """Adds memory stats for browser, renderer and gpu processes.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 AddResult('VMPeak', 'vm_peak_size', 223 AddResult('VMPeak', 'vm_peak_size',
220 'The peak Virtual Memory Size (address space allocated) usage ' 224 'The peak Virtual Memory Size (address space allocated) usage '
221 'achieved by the * process.') 225 'achieved by the * process.')
222 AddResult('WorkingSetSizePeak', '%s_peak_size' % metric, 226 AddResult('WorkingSetSizePeak', '%s_peak_size' % metric,
223 'Peak Working Set Size.') 227 'Peak Working Set Size.')
224 228
225 AddResultsForProcessTypes(['Browser'], 'browser') 229 AddResultsForProcessTypes(['Browser'], 'browser')
226 AddResultsForProcessTypes(['Renderer'], 'renderer') 230 AddResultsForProcessTypes(['Renderer'], 'renderer')
227 AddResultsForProcessTypes(['Gpu'], 'gpu') 231 AddResultsForProcessTypes(['Gpu'], 'gpu')
228 AddResultsForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') 232 AddResultsForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total')
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698