OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 from telemetry.value import scalar | 5 from telemetry.value import scalar |
6 | 6 |
7 from metrics import memory | 7 from metrics import memory |
8 from metrics import Metric | 8 from metrics import Metric |
9 | 9 |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 def Stop(self, page, tab): | 31 def Stop(self, page, tab): |
32 """Prepare the results for this page. | 32 """Prepare the results for this page. |
33 | 33 |
34 The results are the differences between the current system memory stats | 34 The results are the differences between the current system memory stats |
35 and the values when Start() was called. | 35 and the values when Start() was called. |
36 """ | 36 """ |
37 assert self._memory_stats_start, 'Must call Start() first' | 37 assert self._memory_stats_start, 'Must call Start() first' |
38 self._memory_stats_end = self._browser.memory_stats | 38 self._memory_stats_end = self._browser.memory_stats |
39 | 39 |
40 # |trace_name| and |exclude_metrics| args are not in base class Metric. | 40 # |trace_name| and |exclude_metrics| args are not in base class Metric. |
41 # pylint: disable=W0221 | 41 # pylint: disable=arguments-differ |
42 def AddResults(self, tab, results, trace_name=None, exclude_metrics=None): | 42 def AddResults(self, tab, results, trace_name=None, exclude_metrics=None): |
43 """Add results for this page to the results object. | 43 """Add results for this page to the results object. |
44 | 44 |
45 Reports the delta in memory stats between the start stats and the end stats | 45 Reports the delta in memory stats between the start stats and the end stats |
46 (as *_delta metrics). It reports end memory stats in case no matching start | 46 (as *_delta metrics). It reports end memory stats in case no matching start |
47 memory stats exists. | 47 memory stats exists. |
48 | 48 |
49 Args: | 49 Args: |
50 trace_name: Trace name to identify the summary results for current page. | 50 trace_name: Trace name to identify the summary results for current page. |
51 exclude_metrics: List of memory metrics to exclude from results, | 51 exclude_metrics: List of memory metrics to exclude from results, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 memory_stats[process_type] = end_process_memory - start_value | 116 memory_stats[process_type] = end_process_memory - start_value |
117 else: | 117 else: |
118 for metric in end_process_memory: | 118 for metric in end_process_memory: |
119 end_value = end_process_memory[metric] | 119 end_value = end_process_memory[metric] |
120 start_value = start_memory_stats[process_type].get(metric, 0) | 120 start_value = start_memory_stats[process_type].get(metric, 0) |
121 if 'Peak' in metric: | 121 if 'Peak' in metric: |
122 memory_stats[process_type][metric] = end_value | 122 memory_stats[process_type][metric] = end_value |
123 else: | 123 else: |
124 memory_stats[process_type][metric] = end_value - start_value | 124 memory_stats[process_type][metric] = end_value - start_value |
125 return memory_stats | 125 return memory_stats |
OLD | NEW |