OLD | NEW |
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 Metric | 7 from metrics import Metric |
8 from telemetry.value import histogram | 8 from telemetry.value import histogram |
9 from telemetry.value import histogram_util | 9 from telemetry.value import histogram_util |
10 from telemetry.value import scalar | 10 from telemetry.value import scalar |
11 | 11 |
12 | 12 |
13 _HISTOGRAMS = [ | 13 _HISTOGRAMS = [ |
14 { | 14 { |
15 'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent', | 15 'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent', |
16 'display_name': 'V8_MemoryExternalFragmentationTotal', | 16 'display_name': 'V8_MemoryExternalFragmentationTotal', |
17 'type': histogram_util.RENDERER_HISTOGRAM, | 17 'type': histogram_util.RENDERER_HISTOGRAM, |
18 'description': 'Total external memory fragmentation after each GC in ' | 18 'description': 'Total external memory fragmentation after each GC in ' |
19 'percent.', | 19 'percent.', |
| 20 'higher_is_better': False, |
20 }, | 21 }, |
21 { | 22 { |
22 'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb', | 23 'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb', |
23 'display_name': 'V8_MemoryHeapSampleTotalCommitted', | 24 'display_name': 'V8_MemoryHeapSampleTotalCommitted', |
24 'type': histogram_util.RENDERER_HISTOGRAM, | 25 'type': histogram_util.RENDERER_HISTOGRAM, |
25 'description': 'The total size of committed memory used by V8 after ' | 26 'description': 'The total size of committed memory used by V8 after ' |
26 'each GC in KB.' | 27 'each GC in KB.', |
| 28 'higher_is_better': False, |
27 }, | 29 }, |
28 { | 30 { |
29 'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb', | 31 'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb', |
30 'display_name': 'V8_MemoryHeapSampleTotalUsed', | 32 'display_name': 'V8_MemoryHeapSampleTotalUsed', |
31 'type': histogram_util.RENDERER_HISTOGRAM, | 33 'type': histogram_util.RENDERER_HISTOGRAM, |
32 'description': 'The total size of live memory used by V8 after each ' | 34 'description': 'The total size of live memory used by V8 after each ' |
33 'GC in KB.', | 35 'GC in KB.', |
| 36 'higher_is_better': False, |
34 }, | 37 }, |
35 { | 38 { |
36 'name': 'V8.MemoryHeapSampleMaximumCommitted', 'units': 'kb', | 39 'name': 'V8.MemoryHeapSampleMaximumCommitted', 'units': 'kb', |
37 'display_name': 'V8_MemoryHeapSampleMaximumCommitted', | 40 'display_name': 'V8_MemoryHeapSampleMaximumCommitted', |
38 'type': histogram_util.RENDERER_HISTOGRAM | 41 'type': histogram_util.RENDERER_HISTOGRAM, |
| 42 'higher_is_better': False, |
39 }, | 43 }, |
40 { | 44 { |
41 'name': 'Memory.RendererUsed', 'units': 'kb', | 45 'name': 'Memory.RendererUsed', 'units': 'kb', |
42 'display_name': 'Memory_RendererUsed', | 46 'display_name': 'Memory_RendererUsed', |
43 'type': histogram_util.RENDERER_HISTOGRAM | 47 'type': histogram_util.RENDERER_HISTOGRAM, |
| 48 'higher_is_better': False, |
44 }, | 49 }, |
45 { | 50 { |
46 'name': 'Memory.BrowserUsed', 'units': 'kb', | 51 'name': 'Memory.BrowserUsed', 'units': 'kb', |
47 'display_name': 'Memory_BrowserUsed', | 52 'display_name': 'Memory_BrowserUsed', |
48 'type': histogram_util.BROWSER_HISTOGRAM | 53 'type': histogram_util.BROWSER_HISTOGRAM, |
| 54 'higher_is_better': False, |
49 }, | 55 }, |
50 ] | 56 ] |
51 | 57 |
52 class MemoryMetric(Metric): | 58 class MemoryMetric(Metric): |
53 """MemoryMetric gathers memory statistics from the browser object. | 59 """MemoryMetric gathers memory statistics from the browser object. |
54 | 60 |
55 This includes both per-page histogram stats, most about javascript | 61 This includes both per-page histogram stats, most about javascript |
56 memory usage, and overall memory stats from the system for the whole | 62 memory usage, and overall memory stats from the system for the whole |
57 test run.""" | 63 test run.""" |
58 | 64 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 def AddResults(self, tab, results, trace_name=None): | 120 def AddResults(self, tab, results, trace_name=None): |
115 """Add results for this page to the results object.""" | 121 """Add results for this page to the results object.""" |
116 assert self._histogram_delta, 'Must call Stop() first' | 122 assert self._histogram_delta, 'Must call Stop() first' |
117 for h in _HISTOGRAMS: | 123 for h in _HISTOGRAMS: |
118 # Histogram data may not be available | 124 # Histogram data may not be available |
119 if h['name'] not in self._histogram_start: | 125 if h['name'] not in self._histogram_start: |
120 continue | 126 continue |
121 results.AddValue(histogram.HistogramValue( | 127 results.AddValue(histogram.HistogramValue( |
122 results.current_page, h['display_name'], h['units'], | 128 results.current_page, h['display_name'], h['units'], |
123 raw_value_json=self._histogram_delta[h['name']], important=False, | 129 raw_value_json=self._histogram_delta[h['name']], important=False, |
124 description=h.get('description'))) | 130 description=h.get('description'), |
| 131 higher_is_better=h.get('higher_is_better'))) |
125 self._memory_stats = self._browser.memory_stats | 132 self._memory_stats = self._browser.memory_stats |
126 if not self._memory_stats['Browser']: | 133 if not self._memory_stats['Browser']: |
127 return | 134 return |
128 AddResultsForProcesses(results, self._memory_stats, | 135 AddResultsForProcesses(results, self._memory_stats, |
129 metric_trace_name=trace_name) | 136 metric_trace_name=trace_name) |
130 | 137 |
131 if self._start_commit_charge: | 138 if self._start_commit_charge: |
132 end_commit_charge = self._memory_stats['SystemCommitCharge'] | 139 end_commit_charge = self._memory_stats['SystemCommitCharge'] |
133 commit_charge_difference = end_commit_charge - self._start_commit_charge | 140 commit_charge_difference = end_commit_charge - self._start_commit_charge |
134 results.AddValue(scalar.ScalarValue( | 141 results.AddValue(scalar.ScalarValue( |
135 results.current_page, | 142 results.current_page, |
136 'commit_charge.' + (trace_name or 'commit_charge'), | 143 'commit_charge.' + (trace_name or 'commit_charge'), |
137 'kb', commit_charge_difference, important=False, | 144 'kb', commit_charge_difference, important=False, |
138 description='System commit charge (committed memory pages).')) | 145 description='System commit charge (committed memory pages).', |
| 146 higher_is_better=False)) |
139 results.AddValue(scalar.ScalarValue( | 147 results.AddValue(scalar.ScalarValue( |
140 results.current_page, 'processes.' + (trace_name or 'processes'), | 148 results.current_page, 'processes.' + (trace_name or 'processes'), |
141 'count', self._memory_stats['ProcessCount'], important=False, | 149 'count', self._memory_stats['ProcessCount'], important=False, |
142 description='Number of processes used by Chrome.')) | 150 description='Number of processes used by Chrome.', |
| 151 higher_is_better=False)) |
143 | 152 |
144 | 153 |
145 def AddResultsForProcesses(results, memory_stats, chart_trace_name='final', | 154 def AddResultsForProcesses(results, memory_stats, chart_trace_name='final', |
146 metric_trace_name=None, | 155 metric_trace_name=None, |
147 exclude_metrics=None): | 156 exclude_metrics=None): |
148 """Adds memory stats for browser, renderer and gpu processes. | 157 """Adds memory stats for browser, renderer and gpu processes. |
149 | 158 |
150 Args: | 159 Args: |
151 results: A telemetry.results.PageTestResults object. | 160 results: A telemetry.results.PageTestResults object. |
152 memory_stats: System memory stats collected. | 161 memory_stats: System memory stats collected. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 values.append(stats[value_name_memory]) | 195 values.append(stats[value_name_memory]) |
187 if values: | 196 if values: |
188 if metric_trace_name: | 197 if metric_trace_name: |
189 current_trace = '%s_%s' % (metric_trace_name, process_type_trace) | 198 current_trace = '%s_%s' % (metric_trace_name, process_type_trace) |
190 chart_name = value_name_trace | 199 chart_name = value_name_trace |
191 else: | 200 else: |
192 current_trace = '%s_%s' % (value_name_trace, process_type_trace) | 201 current_trace = '%s_%s' % (value_name_trace, process_type_trace) |
193 chart_name = current_trace | 202 chart_name = current_trace |
194 results.AddValue(scalar.ScalarValue( | 203 results.AddValue(scalar.ScalarValue( |
195 results.current_page, '%s.%s' % (chart_name, current_trace), 'kb', | 204 results.current_page, '%s.%s' % (chart_name, current_trace), 'kb', |
196 sum(values) / 1024, important=False, description=description)) | 205 sum(values) / 1024, important=False, description=description, |
| 206 higher_is_better=False)) |
197 | 207 |
198 AddResult('VM', 'vm_%s_size' % chart_trace_name, | 208 AddResult('VM', 'vm_%s_size' % chart_trace_name, |
199 'Virtual Memory Size (address space allocated).') | 209 'Virtual Memory Size (address space allocated).') |
200 AddResult('WorkingSetSize', 'vm_%s_%s_size' % (metric, chart_trace_name), | 210 AddResult('WorkingSetSize', 'vm_%s_%s_size' % (metric, chart_trace_name), |
201 'Working Set Size (Windows) or Resident Set Size (other ' | 211 'Working Set Size (Windows) or Resident Set Size (other ' |
202 'platforms).') | 212 'platforms).') |
203 AddResult('PrivateDirty', 'vm_private_dirty_%s' % chart_trace_name, | 213 AddResult('PrivateDirty', 'vm_private_dirty_%s' % chart_trace_name, |
204 'Private Dirty is basically the amount of RAM inside the ' | 214 'Private Dirty is basically the amount of RAM inside the ' |
205 'process that can not be paged to disk (it is not backed by the ' | 215 'process that can not be paged to disk (it is not backed by the ' |
206 'same data on disk), and is not shared with any other ' | 216 'same data on disk), and is not shared with any other ' |
(...skipping 16 matching lines...) Expand all Loading... |
223 AddResult('VMPeak', 'vm_peak_size', | 233 AddResult('VMPeak', 'vm_peak_size', |
224 'The peak Virtual Memory Size (address space allocated) usage ' | 234 'The peak Virtual Memory Size (address space allocated) usage ' |
225 'achieved by the * process.') | 235 'achieved by the * process.') |
226 AddResult('WorkingSetSizePeak', '%s_peak_size' % metric, | 236 AddResult('WorkingSetSizePeak', '%s_peak_size' % metric, |
227 'Peak Working Set Size.') | 237 'Peak Working Set Size.') |
228 | 238 |
229 AddResultsForProcessTypes(['Browser'], 'browser') | 239 AddResultsForProcessTypes(['Browser'], 'browser') |
230 AddResultsForProcessTypes(['Renderer'], 'renderer') | 240 AddResultsForProcessTypes(['Renderer'], 'renderer') |
231 AddResultsForProcessTypes(['Gpu'], 'gpu') | 241 AddResultsForProcessTypes(['Gpu'], 'gpu') |
232 AddResultsForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') | 242 AddResultsForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') |
OLD | NEW |