| OLD | NEW |
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 10 matching lines...) Expand all Loading... |
| 21 from telemetry.core import util | 21 from telemetry.core import util |
| 22 from telemetry.page import page_test | 22 from telemetry.page import page_test |
| 23 from telemetry.value import scalar | 23 from telemetry.value import scalar |
| 24 | 24 |
| 25 from metrics import cpu | 25 from metrics import cpu |
| 26 from metrics import keychain_metric | 26 from metrics import keychain_metric |
| 27 from metrics import memory | 27 from metrics import memory |
| 28 from metrics import power | 28 from metrics import power |
| 29 from metrics import speedindex | 29 from metrics import speedindex |
| 30 | 30 |
| 31 from telemetry.timeline import tracing_config |
| 32 from telemetry.timeline import tracing_category_filter |
| 33 |
| 31 | 34 |
| 32 class PageCycler(page_test.PageTest): | 35 class PageCycler(page_test.PageTest): |
| 33 | 36 |
| 34 def __init__(self, page_repeat, pageset_repeat, cold_load_percent=50, | 37 def __init__(self, page_repeat, pageset_repeat, cold_load_percent=50, |
| 35 report_speed_index=False, clear_cache_before_each_run=False): | 38 report_speed_index=False, clear_cache_before_each_run=False): |
| 36 super(PageCycler, self).__init__( | 39 super(PageCycler, self).__init__( |
| 37 clear_cache_before_each_run=clear_cache_before_each_run) | 40 clear_cache_before_each_run=clear_cache_before_each_run) |
| 38 | 41 |
| 39 with open(os.path.join(os.path.dirname(__file__), | 42 with open(os.path.join(os.path.dirname(__file__), |
| 40 'page_cycler.js'), 'r') as f: | 43 'page_cycler.js'), 'r') as f: |
| (...skipping 27 matching lines...) Expand all Loading... |
| 68 def WillStartBrowser(self, platform): | 71 def WillStartBrowser(self, platform): |
| 69 """Initialize metrics once right before the browser has been launched.""" | 72 """Initialize metrics once right before the browser has been launched.""" |
| 70 self._power_metric = power.PowerMetric(platform) | 73 self._power_metric = power.PowerMetric(platform) |
| 71 | 74 |
| 72 def DidStartBrowser(self, browser): | 75 def DidStartBrowser(self, browser): |
| 73 """Initialize metrics once right after the browser has been launched.""" | 76 """Initialize metrics once right after the browser has been launched.""" |
| 74 self._memory_metric = memory.MemoryMetric(browser) | 77 self._memory_metric = memory.MemoryMetric(browser) |
| 75 self._cpu_metric = cpu.CpuMetric(browser) | 78 self._cpu_metric = cpu.CpuMetric(browser) |
| 76 | 79 |
| 77 def WillNavigateToPage(self, page, tab): | 80 def WillNavigateToPage(self, page, tab): |
| 81 category_filter = tracing_category_filter.TracingCategoryFilter( |
| 82 'blink.user_timing') |
| 83 config = tracing_config.TracingConfig() |
| 84 config.SetTracingCategoryFilter(category_filter) |
| 85 tab.browser.platform.tracing_controller.StartTracing(config) |
| 78 if page.is_file: | 86 if page.is_file: |
| 79 # For legacy page cyclers which use the filesystem, do an initial | 87 # For legacy page cyclers which use the filesystem, do an initial |
| 80 # navigate to avoid paying for a cross-renderer navigation. | 88 # navigate to avoid paying for a cross-renderer navigation. |
| 81 initial_url = tab.browser.platform.http_server.UrlOf('nonexistent.html') | 89 initial_url = tab.browser.platform.http_server.UrlOf('nonexistent.html') |
| 82 if self._initial_renderer_url != initial_url: | 90 if self._initial_renderer_url != initial_url: |
| 83 self._initial_renderer_url = initial_url | 91 self._initial_renderer_url = initial_url |
| 84 tab.Navigate(self._initial_renderer_url) | 92 tab.Navigate(self._initial_renderer_url) |
| 85 | 93 |
| 86 page.script_to_evaluate_on_commit = self._page_cycler_js | 94 page.script_to_evaluate_on_commit = self._page_cycler_js |
| 87 if self.ShouldRunCold(page.url): | 95 if self.ShouldRunCold(page.url): |
| (...skipping 27 matching lines...) Expand all Loading... |
| 115 'ms', tab.EvaluateJavaScript('__pc_load_time'), | 123 'ms', tab.EvaluateJavaScript('__pc_load_time'), |
| 116 description='Average page load time. Measured from ' | 124 description='Average page load time. Measured from ' |
| 117 'performance.timing.navigationStart until the completion ' | 125 'performance.timing.navigationStart until the completion ' |
| 118 'time of a layout after the window.load event. Cold times ' | 126 'time of a layout after the window.load event. Cold times ' |
| 119 'are the times when the page is loaded cold, i.e. without ' | 127 'are the times when the page is loaded cold, i.e. without ' |
| 120 'loading it before, and warm times are times when the ' | 128 'loading it before, and warm times are times when the ' |
| 121 'page is loaded after being loaded previously.')) | 129 'page is loaded after being loaded previously.')) |
| 122 | 130 |
| 123 self._has_loaded_page[page.url] += 1 | 131 self._has_loaded_page[page.url] += 1 |
| 124 | 132 |
| 133 tab.browser.platform.tracing_controller.StopTracing() |
| 125 self._power_metric.Stop(page, tab) | 134 self._power_metric.Stop(page, tab) |
| 126 self._memory_metric.Stop(page, tab) | 135 self._memory_metric.Stop(page, tab) |
| 127 self._memory_metric.AddResults(tab, results) | 136 self._memory_metric.AddResults(tab, results) |
| 128 self._power_metric.AddResults(tab, results) | 137 self._power_metric.AddResults(tab, results) |
| 129 | 138 |
| 130 self._cpu_metric.Stop(page, tab) | 139 self._cpu_metric.Stop(page, tab) |
| 131 self._cpu_metric.AddResults(tab, results) | 140 self._cpu_metric.AddResults(tab, results) |
| 132 | 141 |
| 133 if self._report_speed_index: | 142 if self._report_speed_index: |
| 134 def SpeedIndexIsFinished(): | 143 def SpeedIndexIsFinished(): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 147 # preserve any initial profile cache for as long as possible. | 156 # preserve any initial profile cache for as long as possible. |
| 148 # The second is that, if we did cold runs first, we'd have a transition | 157 # The second is that, if we did cold runs first, we'd have a transition |
| 149 # page set during which we wanted the run for each URL to both | 158 # page set during which we wanted the run for each URL to both |
| 150 # contribute to the cold data and warm the catch for the following | 159 # contribute to the cold data and warm the catch for the following |
| 151 # warm run, and clearing the cache before the load of the following | 160 # warm run, and clearing the cache before the load of the following |
| 152 # URL would eliminate the intended warmup for the previous URL. | 161 # URL would eliminate the intended warmup for the previous URL. |
| 153 return self._has_loaded_page[url] >= self._cold_run_start_index | 162 return self._has_loaded_page[url] >= self._cold_run_start_index |
| 154 | 163 |
| 155 def DidRunPage(self, platform): | 164 def DidRunPage(self, platform): |
| 156 self._power_metric.Close() | 165 self._power_metric.Close() |
| OLD | NEW |