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

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

Issue 91573003: Make page_cycler.py fully measure memory for each page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Shadi's comment Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « tools/perf/measurements/page_cycler.py ('k') | tools/telemetry/telemetry/core/browser.py » ('j') | 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 9
10 _HISTOGRAMS = [ 10 _HISTOGRAMS = [
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 assert self._histogram_start, 'Must call Start() first' 70 assert self._histogram_start, 'Must call Start() first'
71 for h in _HISTOGRAMS: 71 for h in _HISTOGRAMS:
72 # Histogram data may not be available 72 # Histogram data may not be available
73 if h['name'] not in self._histogram_start: 73 if h['name'] not in self._histogram_start:
74 continue 74 continue
75 histogram_data = histogram_util.GetHistogram( 75 histogram_data = histogram_util.GetHistogram(
76 h['type'], h['name'], tab) 76 h['type'], h['name'], tab)
77 self._histogram_delta[h['name']] = histogram_util.SubtractHistogram( 77 self._histogram_delta[h['name']] = histogram_util.SubtractHistogram(
78 histogram_data, self._histogram_start[h['name']]) 78 histogram_data, self._histogram_start[h['name']])
79 79
80 def AddResults(self, tab, results): 80 # Optional argument trace_name is not in base class Metric.
81 # pylint: disable=W0221
82 def AddResults(self, tab, results, trace_name=None):
81 """Add results for this page to the results object.""" 83 """Add results for this page to the results object."""
82 assert self._histogram_delta, 'Must call Stop() first' 84 assert self._histogram_delta, 'Must call Stop() first'
83 for h in _HISTOGRAMS: 85 for h in _HISTOGRAMS:
84 # Histogram data may not be available 86 # Histogram data may not be available
85 if h['name'] not in self._histogram_start: 87 if h['name'] not in self._histogram_start:
86 continue 88 continue
87 results.Add(h['name'], h['units'], self._histogram_delta[h['name']], 89 results.Add(h['name'], h['units'], self._histogram_delta[h['name']],
88 data_type='unimportant-histogram') 90 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 91 self._memory_stats = self._browser.memory_stats
93 if not self._memory_stats['Browser']: 92 if not self._memory_stats['Browser']:
94 return 93 return
95 94
96 metric = 'resident_set_size' 95 metric = 'resident_set_size'
97 if sys.platform == 'win32': 96 if sys.platform == 'win32':
98 metric = 'working_set' 97 metric = 'working_set'
99 98
100 def AddSummariesForProcessTypes(process_types_memory, process_type_trace): 99 def AddResultsForProcessTypes(process_types_memory, process_type_trace):
101 """Add all summaries to the results for a given set of process types. 100 """Add all results for a given set of process types.
102 101
103 Args: 102 Args:
104 process_types_memory: A list of process types, e.g. Browser, 'Renderer' 103 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 104 process_type_trace: The name of this set of process types in the output
106 """ 105 """
107 def AddSummary(value_name_memory, value_name_trace): 106 def AddResult(value_name_memory, value_name_trace):
108 """Add a summary to the results for a given statistic. 107 """Add a result for a given statistic.
109 108
110 Args: 109 Args:
111 value_name_memory: Name of some statistic, e.g. VM, WorkingSetSize 110 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 111 value_name_trace: Name of this statistic to be used in the output
113 """ 112 """
114 if len(process_types_memory) > 1 and value_name_memory.endswith('Peak'): 113 if len(process_types_memory) > 1 and value_name_memory.endswith('Peak'):
115 return 114 return
116 values = [] 115 values = []
117 for process_type_memory in process_types_memory: 116 for process_type_memory in process_types_memory:
118 stats = self._memory_stats[process_type_memory] 117 stats = self._memory_stats[process_type_memory]
119 if value_name_memory in stats: 118 if value_name_memory in stats:
120 values.append(stats[value_name_memory]) 119 values.append(stats[value_name_memory])
121 if values: 120 if values:
122 if trace_name: 121 if trace_name:
123 current_trace = '%s_%s' % (trace_name, process_type_trace) 122 current_trace = '%s_%s' % (trace_name, process_type_trace)
124 chart_name = value_name_trace 123 chart_name = value_name_trace
125 else: 124 else:
126 current_trace = '%s_%s' % (value_name_trace, process_type_trace) 125 current_trace = '%s_%s' % (value_name_trace, process_type_trace)
127 chart_name = current_trace 126 chart_name = current_trace
128 results.AddSummary(current_trace, 'bytes', sum(values), 127 results.Add(current_trace, 'bytes', sum(values),
129 chart_name=chart_name, data_type='unimportant') 128 chart_name=chart_name, data_type='unimportant')
130 129
131 AddSummary('VM', 'vm_final_size') 130 AddResult('VM', 'vm_final_size')
132 AddSummary('WorkingSetSize', 'vm_%s_final_size' % metric) 131 AddResult('WorkingSetSize', 'vm_%s_final_size' % metric)
133 AddSummary('PrivateDirty', 'vm_private_dirty_final') 132 AddResult('PrivateDirty', 'vm_private_dirty_final')
134 AddSummary('ProportionalSetSize', 'vm_proportional_set_size_final') 133 AddResult('ProportionalSetSize', 'vm_proportional_set_size_final')
135 AddSummary('SharedDirty', 'vm_shared_dirty_final') 134 AddResult('SharedDirty', 'vm_shared_dirty_final')
136 AddSummary('VMPeak', 'vm_peak_size') 135 AddResult('VMPeak', 'vm_peak_size')
137 AddSummary('WorkingSetSizePeak', '%s_peak_size' % metric) 136 AddResult('WorkingSetSizePeak', '%s_peak_size' % metric)
138 137
139 AddSummariesForProcessTypes(['Browser'], 'browser') 138 AddResultsForProcessTypes(['Browser'], 'browser')
140 AddSummariesForProcessTypes(['Renderer'], 'renderer') 139 AddResultsForProcessTypes(['Renderer'], 'renderer')
141 AddSummariesForProcessTypes(['Gpu'], 'gpu') 140 AddResultsForProcessTypes(['Gpu'], 'gpu')
142 AddSummariesForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') 141 AddResultsForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total')
143 142
144 end_commit_charge = self._memory_stats['SystemCommitCharge'] 143 end_commit_charge = self._memory_stats['SystemCommitCharge']
145 commit_charge_difference = end_commit_charge - self._start_commit_charge 144 commit_charge_difference = end_commit_charge - self._start_commit_charge
146 results.AddSummary(trace_name or 'commit_charge', 'kb', 145 results.Add(trace_name or 'commit_charge', 'kb',
147 commit_charge_difference, 146 commit_charge_difference,
148 chart_name='commit_charge', 147 chart_name='commit_charge',
149 data_type='unimportant') 148 data_type='unimportant')
150 results.AddSummary(trace_name or 'processes', 'count', 149 results.Add(trace_name or 'processes', 'count',
151 self._memory_stats['ProcessCount'], 150 self._memory_stats['ProcessCount'],
152 chart_name='processes', 151 chart_name='processes',
153 data_type='unimportant') 152 data_type='unimportant')
154
OLDNEW
« no previous file with comments | « tools/perf/measurements/page_cycler.py ('k') | tools/telemetry/telemetry/core/browser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698