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