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 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 Loading... |
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 # TODO(rmcilroy): This is needed for --enable-stats-table. Update once | 167 # TODO(rmcilroy): This is needed for --enable-stats-table. Update once |
168 # https://codereview.chromium.org/22911027/ lands. | 168 # https://codereview.chromium.org/22911027/ lands. |
169 options.AppendExtraBrowserArg('--no-sandbox') | 169 '--no-sandbox' |
| 170 ]) |
170 | 171 |
171 @staticmethod | 172 @staticmethod |
172 def GetV8StatsTable(tab, counters=None): | 173 def GetV8StatsTable(tab, counters=None): |
173 counters = counters or _COUNTER_NAMES | 174 counters = counters or _COUNTER_NAMES |
174 | 175 |
175 return tab.EvaluateJavaScript(""" | 176 return tab.EvaluateJavaScript(""" |
176 (function(counters) { | 177 (function(counters) { |
177 var results = {}; | 178 var results = {}; |
178 if (!window.chrome || !window.chrome.benchmarking) | 179 if (!window.chrome || !window.chrome.benchmarking) |
179 return results; | 180 return results; |
(...skipping 13 matching lines...) Expand all Loading... |
193 """Get the values in the stats table after the page is loaded.""" | 194 """Get the values in the stats table after the page is loaded.""" |
194 self._results = V8ObjectStatsMetric.GetV8StatsTable(tab) | 195 self._results = V8ObjectStatsMetric.GetV8StatsTable(tab) |
195 if not self._results: | 196 if not self._results: |
196 logging.warning('No V8 object stats from website: ' + page.display_name) | 197 logging.warning('No V8 object stats from website: ' + page.display_name) |
197 | 198 |
198 def AddResults(self, tab, results): | 199 def AddResults(self, tab, results): |
199 """Add results for this page to the results object.""" | 200 """Add results for this page to the results object.""" |
200 assert self._results != None, 'Must call Stop() first' | 201 assert self._results != None, 'Must call Stop() first' |
201 for counter_name in self._results: | 202 for counter_name in self._results: |
202 results.Add(counter_name, 'kb', self._results[counter_name] / 1024.0) | 203 results.Add(counter_name, 'kb', self._results[counter_name] / 1024.0) |
OLD | NEW |