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

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

Issue 23512005: BrowserOptions.extra_browser_args is now a set. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: AppendExtraBrowserArgs Created 7 years, 3 months 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
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 json 5 import json
6 import logging 6 import logging
7 7
8 from metrics import Metric 8 from metrics import Metric
9 9
10 _COUNTER_NAMES = [ 10 _COUNTER_NAMES = [
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 It does this by enabling the --track_gc_object_stats flag on V8 and reading 153 It does this by enabling the --track_gc_object_stats flag on V8 and reading
154 these statistics from the StatsTableMetric. 154 these statistics from the StatsTableMetric.
155 """ 155 """
156 156
157 def __init__(self): 157 def __init__(self):
158 super(V8ObjectStatsMetric, self).__init__() 158 super(V8ObjectStatsMetric, self).__init__()
159 self._results = None 159 self._results = None
160 160
161 @classmethod 161 @classmethod
162 def CustomizeBrowserOptions(cls, options): 162 def CustomizeBrowserOptions(cls, options):
163 options.AppendExtraBrowserArg('--enable-stats-table') 163 options.AppendExtraBrowserArgs([
164 options.AppendExtraBrowserArg('--enable-benchmarking') 164 '--enable-stats-table',
165 options.AppendExtraBrowserArg( 165 '--enable-benchmarking',
166 '--js-flags=--track_gc_object_stats --expose_gc') 166 '--js-flags=--track_gc_object_stats --expose_gc'
167 ])
167 168
168 def Start(self, page, tab): 169 def Start(self, page, tab):
169 """Do Nothing.""" 170 """Do Nothing."""
170 pass 171 pass
171 172
172 def Stop(self, page, tab): 173 def Stop(self, page, tab):
173 """Get the values in the stats table after the page is loaded.""" 174 """Get the values in the stats table after the page is loaded."""
174 self._results = tab.EvaluateJavaScript(""" 175 self._results = tab.EvaluateJavaScript("""
175 (function(counters) { 176 (function(counters) {
176 var results = {}; 177 var results = {};
177 if (!window.chrome || !window.chrome.benchmarking) 178 if (!window.chrome || !window.chrome.benchmarking)
178 return results; 179 return results;
179 window.gc(); // Trigger GC to ensure stats are checkpointed. 180 window.gc(); // Trigger GC to ensure stats are checkpointed.
180 for (var i = 0; i < counters.length; i++) 181 for (var i = 0; i < counters.length; i++)
181 results[counters[i]] = chrome.benchmarking.counterForRenderer(counters[i]); 182 results[counters[i]] = chrome.benchmarking.counterForRenderer(counters[i]);
182 return results; 183 return results;
183 })(%s); 184 })(%s);
184 """ % json.dumps(_COUNTER_NAMES)) 185 """ % json.dumps(_COUNTER_NAMES))
185 if not self._results: 186 if not self._results:
186 logging.warning('No V8 object stats from website: ' + page.display_url) 187 logging.warning('No V8 object stats from website: ' + page.display_url)
187 188
188 def AddResults(self, tab, results): 189 def AddResults(self, tab, results):
189 """Add results for this page to the results object.""" 190 """Add results for this page to the results object."""
190 assert self._results != None, 'Must call Stop() first' 191 assert self._results != None, 'Must call Stop() first'
191 for counter_name in self._results: 192 for counter_name in self._results:
192 results.Add(counter_name, 'kb', self._results[counter_name] / 1024.0) 193 results.Add(counter_name, 'kb', self._results[counter_name] / 1024.0)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698