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 histogram_util | 7 from metrics import histogram_util |
8 from metrics import Metric | 8 from metrics import Metric |
9 | 9 |
10 _HISTOGRAMS = [ | 10 _HISTOGRAMS = [ |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 79 |
80 def AddResults(self, tab, results): | 80 def AddResults(self, tab, results): |
81 """Add results for this page to the results object.""" | 81 """Add results for this page to the results object.""" |
82 assert self._histogram_delta, 'Must call Stop() first' | 82 assert self._histogram_delta, 'Must call Stop() first' |
83 for h in _HISTOGRAMS: | 83 for h in _HISTOGRAMS: |
84 # Histogram data may not be available | 84 # Histogram data may not be available |
85 if h['name'] not in self._histogram_start: | 85 if h['name'] not in self._histogram_start: |
86 continue | 86 continue |
87 results.Add(h['name'], h['units'], self._histogram_delta[h['name']], | 87 results.Add(h['name'], h['units'], self._histogram_delta[h['name']], |
88 data_type='unimportant-histogram') | 88 data_type='unimportant-histogram') |
89 | |
90 def AddSummaryResults(self, results, trace_name=None): | |
91 """Add summary (overall) results to the results object.""" | |
92 self._memory_stats = self._browser.memory_stats | 89 self._memory_stats = self._browser.memory_stats |
93 if not self._memory_stats['Browser']: | 90 if not self._memory_stats['Browser']: |
94 return | 91 return |
95 | 92 |
96 metric = 'resident_set_size' | 93 metric = 'resident_set_size' |
97 if sys.platform == 'win32': | 94 if sys.platform == 'win32': |
98 metric = 'working_set' | 95 metric = 'working_set' |
99 | 96 |
100 def AddSummariesForProcessTypes(process_types_memory, process_type_trace): | 97 def AddResultsForProcessTypes(process_types_memory, process_type_trace): |
101 """Add all summaries to the results for a given set of process types. | 98 """Add all results for a given set of process types. |
102 | 99 |
103 Args: | 100 Args: |
104 process_types_memory: A list of process types, e.g. Browser, 'Renderer' | 101 process_types_memory: A list of process types, e.g. Browser, 'Renderer' |
105 process_type_trace: The name of this set of process types in the output | 102 process_type_trace: The name of this set of process types in the output |
106 """ | 103 """ |
107 def AddSummary(value_name_memory, value_name_trace): | 104 def AddResult(value_name_memory, value_name_trace): |
108 """Add a summary to the results for a given statistic. | 105 """Add a result for a given statistic. |
109 | 106 |
110 Args: | 107 Args: |
111 value_name_memory: Name of some statistic, e.g. VM, WorkingSetSize | 108 value_name_memory: Name of some statistic, e.g. VM, WorkingSetSize |
112 value_name_trace: Name of this statistic to be used in the output | 109 value_name_trace: Name of this statistic to be used in the output |
113 """ | 110 """ |
114 if len(process_types_memory) > 1 and value_name_memory.endswith('Peak'): | 111 if len(process_types_memory) > 1 and value_name_memory.endswith('Peak'): |
115 return | 112 return |
116 values = [] | 113 values = [] |
117 for process_type_memory in process_types_memory: | 114 for process_type_memory in process_types_memory: |
118 stats = self._memory_stats[process_type_memory] | 115 stats = self._memory_stats[process_type_memory] |
119 if value_name_memory in stats: | 116 if value_name_memory in stats: |
120 values.append(stats[value_name_memory]) | 117 values.append(stats[value_name_memory]) |
121 if values: | 118 if values: |
122 if trace_name: | 119 current_trace = '%s_%s' % (value_name_trace, process_type_trace) |
shadi
2013/12/02 23:09:02
Why removing all 'trace_name' support? This will b
Philippe
2013/12/03 12:55:00
Should I keep the AddSummaryResults() method and f
| |
123 current_trace = '%s_%s' % (trace_name, process_type_trace) | 120 chart_name = current_trace |
124 chart_name = value_name_trace | 121 results.Add(current_trace, 'bytes', sum(values), |
125 else: | 122 chart_name=chart_name, data_type='unimportant') |
126 current_trace = '%s_%s' % (value_name_trace, process_type_trace) | |
127 chart_name = current_trace | |
128 results.AddSummary(current_trace, 'bytes', sum(values), | |
129 chart_name=chart_name, data_type='unimportant') | |
130 | 123 |
131 AddSummary('VM', 'vm_final_size') | 124 AddResult('VM', 'vm_final_size') |
132 AddSummary('WorkingSetSize', 'vm_%s_final_size' % metric) | 125 AddResult('WorkingSetSize', 'vm_%s_final_size' % metric) |
133 AddSummary('PrivateDirty', 'vm_private_dirty_final') | 126 AddResult('PrivateDirty', 'vm_private_dirty_final') |
134 AddSummary('ProportionalSetSize', 'vm_proportional_set_size_final') | 127 AddResult('ProportionalSetSize', 'vm_proportional_set_size_final') |
135 AddSummary('SharedDirty', 'vm_shared_dirty_final') | 128 AddResult('SharedDirty', 'vm_shared_dirty_final') |
136 AddSummary('VMPeak', 'vm_peak_size') | 129 AddResult('VMPeak', 'vm_peak_size') |
137 AddSummary('WorkingSetSizePeak', '%s_peak_size' % metric) | 130 AddResult('WorkingSetSizePeak', '%s_peak_size' % metric) |
138 | 131 |
139 AddSummariesForProcessTypes(['Browser'], 'browser') | 132 AddResultsForProcessTypes(['Browser'], 'browser') |
140 AddSummariesForProcessTypes(['Renderer'], 'renderer') | 133 AddResultsForProcessTypes(['Renderer'], 'renderer') |
141 AddSummariesForProcessTypes(['Gpu'], 'gpu') | 134 AddResultsForProcessTypes(['Gpu'], 'gpu') |
142 AddSummariesForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') | 135 AddResultsForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') |
143 | 136 |
144 end_commit_charge = self._memory_stats['SystemCommitCharge'] | 137 end_commit_charge = self._memory_stats['SystemCommitCharge'] |
145 commit_charge_difference = end_commit_charge - self._start_commit_charge | 138 commit_charge_difference = end_commit_charge - self._start_commit_charge |
146 results.AddSummary(trace_name or 'commit_charge', 'kb', | 139 results.Add('commit_charge', 'kb', |
147 commit_charge_difference, | 140 commit_charge_difference, |
148 chart_name='commit_charge', | 141 chart_name='commit_charge', |
149 data_type='unimportant') | 142 data_type='unimportant') |
150 results.AddSummary(trace_name or 'processes', 'count', | 143 results.Add('processes', 'count', |
151 self._memory_stats['ProcessCount'], | 144 self._memory_stats['ProcessCount'], |
152 chart_name='processes', | 145 chart_name='processes', |
153 data_type='unimportant') | 146 data_type='unimportant') |
154 | 147 |
148 def AddSummaryResults(self, results, trace_name=None): | |
tonyg
2013/11/27 17:59:58
I think this can just be omitted, right?
qyearsley
2013/11/27 19:01:55
In general, Metrics don't need to have a method Ad
Philippe
2013/11/28 10:30:13
Yeah, I removed this method.
| |
149 # This metric only returns per-page results. | |
150 raise NotImplementedError() | |
OLD | NEW |