Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 'V8.MemoryMapSpaceBytesCommitted', | 25 'V8.MemoryMapSpaceBytesCommitted', |
| 26 'V8.MemoryMapSpaceBytesUsed', | 26 'V8.MemoryMapSpaceBytesUsed', |
| 27 'V8.MemoryCellSpaceBytesAvailable', | 27 'V8.MemoryCellSpaceBytesAvailable', |
| 28 'V8.MemoryCellSpaceBytesCommitted', | 28 'V8.MemoryCellSpaceBytesCommitted', |
| 29 'V8.MemoryCellSpaceBytesUsed', | 29 'V8.MemoryCellSpaceBytesUsed', |
| 30 'V8.MemoryPropertyCellSpaceBytesAvailable', | 30 'V8.MemoryPropertyCellSpaceBytesAvailable', |
| 31 'V8.MemoryPropertyCellSpaceBytesCommitted', | 31 'V8.MemoryPropertyCellSpaceBytesCommitted', |
| 32 'V8.MemoryPropertyCellSpaceBytesUsed', | 32 'V8.MemoryPropertyCellSpaceBytesUsed', |
| 33 'V8.MemoryLoSpaceBytesAvailable', | 33 'V8.MemoryLoSpaceBytesAvailable', |
| 34 'V8.MemoryLoSpaceBytesCommitted', | 34 'V8.MemoryLoSpaceBytesCommitted', |
| 35 'V8.MemoryLoSpaceBytesUsed)', | 35 'V8.MemoryLoSpaceBytesUsed', |
|
rmcilroy
2013/09/04 18:09:21
oops, thanks!
| |
| 36 'V8.SizeOf_ACCESSOR_PAIR_TYPE', | 36 'V8.SizeOf_ACCESSOR_PAIR_TYPE', |
| 37 'V8.SizeOf_ACCESS_CHECK_INFO_TYPE', | 37 'V8.SizeOf_ACCESS_CHECK_INFO_TYPE', |
| 38 'V8.SizeOf_ALIASED_ARGUMENTS_ENTRY_TYPE', | 38 'V8.SizeOf_ALIASED_ARGUMENTS_ENTRY_TYPE', |
| 39 'V8.SizeOf_ALLOCATION_MEMENTO_TYPE', | 39 'V8.SizeOf_ALLOCATION_MEMENTO_TYPE', |
| 40 'V8.SizeOf_ALLOCATION_SITE_TYPE', | 40 'V8.SizeOf_ALLOCATION_SITE_TYPE', |
| 41 'V8.SizeOf_ASCII_INTERNALIZED_STRING_TYPE', | 41 'V8.SizeOf_ASCII_INTERNALIZED_STRING_TYPE', |
| 42 'V8.SizeOf_ASCII_STRING_TYPE', | 42 'V8.SizeOf_ASCII_STRING_TYPE', |
| 43 'V8.SizeOf_BOX_TYPE', | 43 'V8.SizeOf_BOX_TYPE', |
| 44 'V8.SizeOf_BREAK_POINT_INFO_TYPE', | 44 'V8.SizeOf_BREAK_POINT_INFO_TYPE', |
| 45 'V8.SizeOf_BYTE_ARRAY_TYPE', | 45 'V8.SizeOf_BYTE_ARRAY_TYPE', |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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.AppendExtraBrowserArg('--enable-stats-table') |
| 164 options.AppendExtraBrowserArg('--enable-benchmarking') | 164 options.AppendExtraBrowserArg('--enable-benchmarking') |
| 165 options.AppendExtraBrowserArg( | 165 options.AppendExtraBrowserArg( |
| 166 '--js-flags=--track_gc_object_stats --expose_gc') | 166 '--js-flags=--track_gc_object_stats --expose_gc') |
| 167 options.AppendExtraBrowserArg('--no-sandbox') | |
|
tonyg
2013/09/04 17:41:11
I don't see how this is related. Can you explain w
edmundyan
2013/09/04 17:53:41
I needed to add this line over in endure.py, other
rmcilroy
2013/09/04 18:09:21
Ahh yes, this is required for --enable-stats-table
edmundyan
2013/09/04 18:54:02
Done.
/me wonders if there are other browser optio
| |
| 168 | |
| 169 @staticmethod | |
| 170 def GetV8StatsTable(tab, counters=None): | |
| 171 if counters is None: | |
| 172 counters = _COUNTER_NAMES | |
|
tonyg
2013/09/04 17:41:11
Rather than this, can't you just do counters=_COUN
edmundyan
2013/09/04 17:53:41
That is what I did originally, but pylint didn't l
rmcilroy
2013/09/04 18:09:21
Maybe just:
counters = counters or _COUNTER_NAMES
edmundyan
2013/09/04 18:54:02
Done.
| |
| 173 | |
| 174 return tab.EvaluateJavaScript(""" | |
| 175 (function(counters) { | |
| 176 var results = {}; | |
| 177 if (!window.chrome || !window.chrome.benchmarking) | |
| 178 return results; | |
| 179 window.gc(); // Trigger GC to ensure stats are checkpointed. | |
| 180 for (var i = 0; i < counters.length; i++) | |
| 181 results[counters[i]] = | |
| 182 chrome.benchmarking.counterForRenderer(counters[i]); | |
| 183 return results; | |
| 184 })(%s); | |
| 185 """ % json.dumps(counters)) | |
| 167 | 186 |
| 168 def Start(self, page, tab): | 187 def Start(self, page, tab): |
| 169 """Do Nothing.""" | 188 """Do Nothing.""" |
| 170 pass | 189 pass |
| 171 | 190 |
| 172 def Stop(self, page, tab): | 191 def Stop(self, page, tab): |
| 173 """Get the values in the stats table after the page is loaded.""" | 192 """Get the values in the stats table after the page is loaded.""" |
| 174 self._results = tab.EvaluateJavaScript(""" | 193 self._results = V8ObjectStatsMetric.GetV8StatsTable(tab) |
| 175 (function(counters) { | |
| 176 var results = {}; | |
| 177 if (!window.chrome || !window.chrome.benchmarking) | |
| 178 return results; | |
| 179 window.gc(); // Trigger GC to ensure stats are checkpointed. | |
| 180 for (var i = 0; i < counters.length; i++) | |
| 181 results[counters[i]] = chrome.benchmarking.counterForRenderer(counters[i]); | |
| 182 return results; | |
| 183 })(%s); | |
| 184 """ % json.dumps(_COUNTER_NAMES)) | |
| 185 if not self._results: | 194 if not self._results: |
| 186 logging.warning('No V8 object stats from website: ' + page.display_url) | 195 logging.warning('No V8 object stats from website: ' + page.display_url) |
| 187 | 196 |
| 188 def AddResults(self, tab, results): | 197 def AddResults(self, tab, results): |
| 189 """Add results for this page to the results object.""" | 198 """Add results for this page to the results object.""" |
| 190 assert self._results != None, 'Must call Stop() first' | 199 assert self._results != None, 'Must call Stop() first' |
| 191 for counter_name in self._results: | 200 for counter_name in self._results: |
| 192 results.Add(counter_name, 'kb', self._results[counter_name] / 1024.0) | 201 results.Add(counter_name, 'kb', self._results[counter_name] / 1024.0) |
| OLD | NEW |