Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """The page cycler measurement. | 5 """The page cycler measurement. |
| 6 | 6 |
| 7 This measurement registers a window load handler in which is forces a layout and | 7 This measurement registers a window load handler in which is forces a layout and |
| 8 then records the value of performance.now(). This call to now() measures the | 8 then records the value of performance.now(). This call to now() measures the |
| 9 time from navigationStart (immediately after the previous page's beforeunload | 9 time from navigationStart (immediately after the previous page's beforeunload |
| 10 event) until after the layout in the page's load event. In addition, two garbage | 10 event) until after the layout in the page's load event. In addition, two garbage |
| 11 collections are performed in between the page loads (in the beforeunload event). | 11 collections are performed in between the page loads (in the beforeunload event). |
| 12 This extra garbage collection time is not included in the measurement times. | 12 This extra garbage collection time is not included in the measurement times. |
| 13 | 13 |
| 14 Finally, various memory and IO statistics are gathered at the very end of | 14 Finally, various memory and IO statistics are gathered at the very end of |
| 15 cycling all pages. | 15 cycling all pages. |
| 16 """ | 16 """ |
| 17 | 17 |
| 18 import os | 18 import os |
| 19 import sys | 19 import sys |
| 20 | 20 |
| 21 from metrics import histogram | |
| 22 from metrics import memory | 21 from metrics import memory |
| 23 from telemetry.core import util | 22 from telemetry.core import util |
| 24 from telemetry.page import page_measurement | 23 from telemetry.page import page_measurement |
| 25 | 24 |
| 26 | |
| 27 MEMORY_HISTOGRAMS = [ | |
| 28 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, | |
| 29 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'}, | |
| 30 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}] | |
| 31 | |
| 32 | |
| 33 class PageCycler(page_measurement.PageMeasurement): | 25 class PageCycler(page_measurement.PageMeasurement): |
| 34 def __init__(self, *args, **kwargs): | 26 def __init__(self, *args, **kwargs): |
| 35 super(PageCycler, self).__init__(*args, **kwargs) | 27 super(PageCycler, self).__init__(*args, **kwargs) |
| 36 | 28 |
| 37 with open(os.path.join(os.path.dirname(__file__), | 29 with open(os.path.join(os.path.dirname(__file__), |
| 38 'page_cycler.js'), 'r') as f: | 30 'page_cycler.js'), 'r') as f: |
| 39 self._page_cycler_js = f.read() | 31 self._page_cycler_js = f.read() |
| 40 | 32 |
| 41 self._memory_metric = None | 33 self._memory_metric = None |
| 42 self._histograms = None | |
| 43 | 34 |
| 44 def AddCommandLineOptions(self, parser): | 35 def AddCommandLineOptions(self, parser): |
| 45 # The page cyclers should default to 10 iterations. In order to change the | 36 # The page cyclers should default to 10 iterations. In order to change the |
| 46 # default of an option, we must remove and re-add it. | 37 # default of an option, we must remove and re-add it. |
| 47 # TODO: Remove this after transition to run_benchmark. | 38 # TODO: Remove this after transition to run_benchmark. |
| 48 pageset_repeat_option = parser.get_option('--pageset-repeat') | 39 pageset_repeat_option = parser.get_option('--pageset-repeat') |
| 49 pageset_repeat_option.default = 10 | 40 pageset_repeat_option.default = 10 |
| 50 parser.remove_option('--pageset-repeat') | 41 parser.remove_option('--pageset-repeat') |
| 51 parser.add_option(pageset_repeat_option) | 42 parser.add_option(pageset_repeat_option) |
| 52 | 43 |
| 53 def DidStartBrowser(self, browser): | 44 def DidStartBrowser(self, browser): |
| 54 """Initialize metrics once right after the browser has been launched.""" | 45 """Initialize metrics once right after the browser has been launched.""" |
| 55 self._memory_metric = memory.MemoryMetric(browser) | 46 self._memory_metric = memory.MemoryMetric(browser) |
| 56 self._memory_metric.Start() | |
| 57 self._histograms = [histogram.HistogramMetric( | |
| 58 h, histogram.RENDERER_HISTOGRAM) | |
| 59 for h in MEMORY_HISTOGRAMS] | |
| 60 | 47 |
| 61 def DidStartHTTPServer(self, tab): | 48 def DidStartHTTPServer(self, tab): |
| 62 # Avoid paying for a cross-renderer navigation on the first page on legacy | 49 # Avoid paying for a cross-renderer navigation on the first page on legacy |
| 63 # page cyclers which use the filesystem. | 50 # page cyclers which use the filesystem. |
| 64 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html')) | 51 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html')) |
| 65 | 52 |
| 66 def WillNavigateToPage(self, page, tab): | 53 def WillNavigateToPage(self, page, tab): |
| 67 page.script_to_evaluate_on_commit = self._page_cycler_js | 54 page.script_to_evaluate_on_commit = self._page_cycler_js |
| 68 | 55 |
| 69 def DidNavigateToPage(self, page, tab): | 56 def DidNavigateToPage(self, page, tab): |
| 70 for h in self._histograms: | 57 self._memory_metric.Start(page, tab) |
| 71 h.Start(page, tab) | |
| 72 | 58 |
| 73 def CustomizeBrowserOptions(self, options): | 59 def CustomizeBrowserOptions(self, options): |
| 74 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') | 60 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') |
| 75 options.AppendExtraBrowserArg('--js-flags=--expose_gc') | 61 options.AppendExtraBrowserArg('--js-flags=--expose_gc') |
| 76 options.AppendExtraBrowserArg('--no-sandbox') | 62 options.AppendExtraBrowserArg('--no-sandbox') |
| 77 | 63 |
| 78 # Old commandline flags used for reference builds. | 64 # Old commandline flags used for reference builds. |
| 79 options.AppendExtraBrowserArg('--dom-automation') | 65 options.AppendExtraBrowserArg('--dom-automation') |
| 80 | 66 |
| 81 # Temporarily disable typical_25 page set on mac. | 67 # Temporarily disable typical_25 page set on mac. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 107 if 'WriteTransferCount' in io_stats[process_type_io]: | 93 if 'WriteTransferCount' in io_stats[process_type_io]: |
| 108 results.AddSummary('write_bytes_' + process_type_trace, 'kb', | 94 results.AddSummary('write_bytes_' + process_type_trace, 'kb', |
| 109 io_stats[process_type_io] | 95 io_stats[process_type_io] |
| 110 ['WriteTransferCount'] / 1024, | 96 ['WriteTransferCount'] / 1024, |
| 111 data_type='unimportant') | 97 data_type='unimportant') |
| 112 AddSummariesForProcessType('Browser', 'browser') | 98 AddSummariesForProcessType('Browser', 'browser') |
| 113 AddSummariesForProcessType('Renderer', 'renderer') | 99 AddSummariesForProcessType('Renderer', 'renderer') |
| 114 AddSummariesForProcessType('Gpu', 'gpu') | 100 AddSummariesForProcessType('Gpu', 'gpu') |
| 115 | 101 |
| 116 def MeasurePage(self, page, tab, results): | 102 def MeasurePage(self, page, tab, results): |
| 103 self._memory_metric.Stop(page, tab) | |
| 104 self._memory_metric.AddResults(tab, results) | |
|
tonyg
2013/08/09 01:43:44
I think these need to be after we wait for the pag
qyearsley
2013/08/09 16:43:15
Yeah -- that's how it has been, so if want to keep
| |
| 105 | |
| 117 def _IsDone(): | 106 def _IsDone(): |
| 118 return bool(tab.EvaluateJavaScript('__pc_load_time')) | 107 return bool(tab.EvaluateJavaScript('__pc_load_time')) |
| 119 util.WaitFor(_IsDone, 60) | 108 util.WaitFor(_IsDone, 60) |
| 120 | |
| 121 for h in self._histograms: | |
| 122 h.GetValue(page, tab, results) | |
| 123 | |
| 124 results.Add('page_load_time', 'ms', | 109 results.Add('page_load_time', 'ms', |
| 125 int(float(tab.EvaluateJavaScript('__pc_load_time'))), | 110 int(float(tab.EvaluateJavaScript('__pc_load_time'))), |
| 126 chart_name='times') | 111 chart_name='times') |
| 127 | 112 |
| 128 def DidRunTest(self, tab, results): | 113 def DidRunTest(self, tab, results): |
| 129 self._memory_metric.Stop() | 114 self._memory_metric.AddSummaryResults(results) |
| 130 self._memory_metric.AddResults(tab, results) | |
| 131 self.MeasureIO(tab, results) | 115 self.MeasureIO(tab, results) |
| 132 | 116 |
| OLD | NEW |