| 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 28 matching lines...) Expand all Loading... |
| 39 'page_cycler.js'), 'r') as f: | 39 'page_cycler.js'), 'r') as f: |
| 40 self._page_cycler_js = f.read() | 40 self._page_cycler_js = f.read() |
| 41 | 41 |
| 42 self._speedindex_metric = speedindex.SpeedIndexMetric() | 42 self._speedindex_metric = speedindex.SpeedIndexMetric() |
| 43 self._memory_metric = None | 43 self._memory_metric = None |
| 44 self._power_metric = None | 44 self._power_metric = None |
| 45 self._cpu_metric = None | 45 self._cpu_metric = None |
| 46 self._v8_object_stats_metric = None | 46 self._v8_object_stats_metric = None |
| 47 self._has_loaded_page = collections.defaultdict(int) | 47 self._has_loaded_page = collections.defaultdict(int) |
| 48 self._initial_renderer_url = None # to avoid cross-renderer navigation | 48 self._initial_renderer_url = None # to avoid cross-renderer navigation |
| 49 self._record_v8_object_stats = False |
| 50 self._report_speed_index = False |
| 51 self._cold_run_start_index = None |
| 49 | 52 |
| 50 @classmethod | 53 def AddCommandLineArgs(self, parser): |
| 51 def AddCommandLineArgs(cls, parser): | |
| 52 parser.add_option('--v8-object-stats', | 54 parser.add_option('--v8-object-stats', |
| 53 action='store_true', | 55 action='store_true', |
| 54 help='Enable detailed V8 object statistics.') | 56 help='Enable detailed V8 object statistics.') |
| 55 | 57 |
| 56 parser.add_option('--report-speed-index', | 58 parser.add_option('--report-speed-index', |
| 57 action='store_true', | 59 action='store_true', |
| 58 help='Enable the speed index metric.') | 60 help='Enable the speed index metric.') |
| 59 | 61 |
| 60 parser.add_option('--cold-load-percent', type='int', default=50, | 62 parser.add_option('--cold-load-percent', type='int', default=50, |
| 61 help='%d of page visits for which a cold load is forced') | 63 help='%d of page visits for which a cold load is forced') |
| 62 | 64 |
| 63 @classmethod | 65 def ProcessCommandLineArgs(self, parser, args): |
| 64 def ProcessCommandLineArgs(cls, parser, args): | 66 self._record_v8_object_stats = args.v8_object_stats |
| 65 cls._record_v8_object_stats = args.v8_object_stats | 67 self._report_speed_index = args.report_speed_index |
| 66 cls._report_speed_index = args.report_speed_index | |
| 67 | 68 |
| 68 cold_runs_percent_set = (args.cold_load_percent != None) | 69 cold_runs_percent_set = (args.cold_load_percent != None) |
| 69 # Handle requests for cold cache runs | 70 # Handle requests for cold cache runs |
| 70 if (cold_runs_percent_set and | 71 if (cold_runs_percent_set and |
| 71 (args.cold_load_percent < 0 or args.cold_load_percent > 100)): | 72 (args.cold_load_percent < 0 or args.cold_load_percent > 100)): |
| 72 raise Exception('--cold-load-percent must be in the range [0-100]') | 73 raise Exception('--cold-load-percent must be in the range [0-100]') |
| 73 | 74 |
| 74 # Make sure _cold_run_start_index is an integer multiple of page_repeat. | 75 # Make sure _cold_run_start_index is an integer multiple of page_repeat. |
| 75 # Without this, --pageset_shuffle + --page_repeat could lead to | 76 # Without this, --pageset_shuffle + --page_repeat could lead to |
| 76 # assertion failures on _started_warm in WillNavigateToPage. | 77 # assertion failures on _started_warm in WillNavigateToPage. |
| 77 if cold_runs_percent_set: | 78 if cold_runs_percent_set: |
| 78 number_warm_pageset_runs = int( | 79 number_warm_pageset_runs = int( |
| 79 (int(args.pageset_repeat) - 1) * (100 - args.cold_load_percent) / 100) | 80 (int(args.pageset_repeat) - 1) * (100 - args.cold_load_percent) / 100) |
| 80 number_warm_runs = number_warm_pageset_runs * args.page_repeat | 81 number_warm_runs = number_warm_pageset_runs * args.page_repeat |
| 81 cls._cold_run_start_index = number_warm_runs + args.page_repeat | 82 self._cold_run_start_index = number_warm_runs + args.page_repeat |
| 82 cls.discard_first_result = (not args.cold_load_percent or | 83 self.discard_first_result = (not args.cold_load_percent or |
| 83 cls.discard_first_result) | 84 self.discard_first_result) |
| 84 else: | 85 else: |
| 85 cls._cold_run_start_index = args.pageset_repeat * args.page_repeat | 86 self._cold_run_start_index = args.pageset_repeat * args.page_repeat |
| 86 | 87 |
| 87 def WillStartBrowser(self, platform): | 88 def WillStartBrowser(self, platform): |
| 88 """Initialize metrics once right before the browser has been launched.""" | 89 """Initialize metrics once right before the browser has been launched.""" |
| 89 self._power_metric = power.PowerMetric(platform) | 90 self._power_metric = power.PowerMetric(platform) |
| 90 | 91 |
| 91 def DidStartBrowser(self, browser): | 92 def DidStartBrowser(self, browser): |
| 92 """Initialize metrics once right after the browser has been launched.""" | 93 """Initialize metrics once right after the browser has been launched.""" |
| 93 self._memory_metric = memory.MemoryMetric(browser) | 94 self._memory_metric = memory.MemoryMetric(browser) |
| 94 self._cpu_metric = cpu.CpuMetric(browser) | 95 self._cpu_metric = cpu.CpuMetric(browser) |
| 95 if self._record_v8_object_stats: | 96 if self._record_v8_object_stats: |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 175 |
| 175 def ShouldRunCold(self, url): | 176 def ShouldRunCold(self, url): |
| 176 # We do the warm runs first for two reasons. The first is so we can | 177 # We do the warm runs first for two reasons. The first is so we can |
| 177 # preserve any initial profile cache for as long as possible. | 178 # preserve any initial profile cache for as long as possible. |
| 178 # The second is that, if we did cold runs first, we'd have a transition | 179 # The second is that, if we did cold runs first, we'd have a transition |
| 179 # page set during which we wanted the run for each URL to both | 180 # page set during which we wanted the run for each URL to both |
| 180 # contribute to the cold data and warm the catch for the following | 181 # contribute to the cold data and warm the catch for the following |
| 181 # warm run, and clearing the cache before the load of the following | 182 # warm run, and clearing the cache before the load of the following |
| 182 # URL would eliminate the intended warmup for the previous URL. | 183 # URL would eliminate the intended warmup for the previous URL. |
| 183 return (self._has_loaded_page[url] >= self._cold_run_start_index) | 184 return (self._has_loaded_page[url] >= self._cold_run_start_index) |
| OLD | NEW |