| 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 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 with open(os.path.join(os.path.dirname(__file__), | 37 with open(os.path.join(os.path.dirname(__file__), |
| 38 'page_cycler.js'), 'r') as f: | 38 'page_cycler.js'), 'r') as f: |
| 39 self._page_cycler_js = f.read() | 39 self._page_cycler_js = f.read() |
| 40 | 40 |
| 41 self._memory_metrics = None | 41 self._memory_metrics = None |
| 42 self._histograms = None | 42 self._histograms = None |
| 43 | 43 |
| 44 def AddCommandLineOptions(self, parser): | 44 def AddCommandLineOptions(self, parser): |
| 45 # The page cyclers should default to 10 iterations. In order to change the | 45 # 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. | 46 # default of an option, we must remove and re-add it. |
| 47 # TODO: Remove this after transition to run_benchmark. |
| 47 pageset_repeat_option = parser.get_option('--pageset-repeat') | 48 pageset_repeat_option = parser.get_option('--pageset-repeat') |
| 48 pageset_repeat_option.default = 10 | 49 pageset_repeat_option.default = 10 |
| 49 parser.remove_option('--pageset-repeat') | 50 parser.remove_option('--pageset-repeat') |
| 50 parser.add_option(pageset_repeat_option) | 51 parser.add_option(pageset_repeat_option) |
| 51 | 52 |
| 52 def SetUpBrowser(self, browser): | 53 def SetUpBrowser(self, browser): |
| 53 self._memory_metrics = memory_metrics.MemoryMetrics() | 54 self._memory_metrics = memory_metrics.MemoryMetrics() |
| 54 self._memory_metrics.Start(browser) | 55 self._memory_metrics.Start(browser) |
| 55 | 56 |
| 56 self._histograms = [histogram_metric.HistogramMetric( | 57 self._histograms = [histogram_metric.HistogramMetric( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 for h in self._histograms: | 121 for h in self._histograms: |
| 121 h.GetValue(page, tab, results) | 122 h.GetValue(page, tab, results) |
| 122 | 123 |
| 123 results.Add('page_load_time', 'ms', | 124 results.Add('page_load_time', 'ms', |
| 124 int(float(tab.EvaluateJavaScript('__pc_load_time'))), | 125 int(float(tab.EvaluateJavaScript('__pc_load_time'))), |
| 125 chart_name='times') | 126 chart_name='times') |
| 126 | 127 |
| 127 def DidRunPageSet(self, tab, results): | 128 def DidRunPageSet(self, tab, results): |
| 128 self._memory_metrics.StopAndGetResults(tab.browser, results) | 129 self._memory_metrics.StopAndGetResults(tab.browser, results) |
| 129 self.MeasureIO(tab, results) | 130 self.MeasureIO(tab, results) |
| OLD | NEW |