Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: tools/perf/measurements/page_cycler.py

Issue 637153002: telemetry: Remove command line args from page test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Suppress pylint E1003 Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 from metrics import memory 23 from metrics import memory
24 from metrics import power 24 from metrics import power
25 from metrics import speedindex 25 from metrics import speedindex
26 from metrics import v8_object_stats 26 from metrics import v8_object_stats
27 from telemetry.core import util 27 from telemetry.core import util
28 from telemetry.page import page_test 28 from telemetry.page import page_test
29 from telemetry.value import scalar 29 from telemetry.value import scalar
30 30
31 31
32 class PageCycler(page_test.PageTest): 32 class PageCycler(page_test.PageTest):
33 options = {'pageset_repeat': 10} 33 def __init__(self, page_repeat, pageset_repeat, cold_load_percent=50,
34 34 record_v8_object_stats=False, report_speed_index=False):
35 def __init__(self, *args, **kwargs): 35 super(PageCycler, self).__init__()
36 super(PageCycler, self).__init__(*args, **kwargs)
37 36
38 with open(os.path.join(os.path.dirname(__file__), 37 with open(os.path.join(os.path.dirname(__file__),
39 'page_cycler.js'), 'r') as f: 38 'page_cycler.js'), 'r') as f:
40 self._page_cycler_js = f.read() 39 self._page_cycler_js = f.read()
41 40
41 self._record_v8_object_stats = record_v8_object_stats
42 self._report_speed_index = report_speed_index
42 self._speedindex_metric = speedindex.SpeedIndexMetric() 43 self._speedindex_metric = speedindex.SpeedIndexMetric()
43 self._memory_metric = None 44 self._memory_metric = None
44 self._power_metric = None 45 self._power_metric = None
45 self._cpu_metric = None 46 self._cpu_metric = None
46 self._v8_object_stats_metric = None 47 self._v8_object_stats_metric = None
47 self._has_loaded_page = collections.defaultdict(int) 48 self._has_loaded_page = collections.defaultdict(int)
48 self._initial_renderer_url = None # to avoid cross-renderer navigation 49 self._initial_renderer_url = None # to avoid cross-renderer navigation
49 50
50 @classmethod 51 cold_runs_percent_set = (cold_load_percent != None)
51 def AddCommandLineArgs(cls, parser):
52 parser.add_option('--v8-object-stats',
53 action='store_true',
54 help='Enable detailed V8 object statistics.')
55
56 parser.add_option('--report-speed-index',
57 action='store_true',
58 help='Enable the speed index metric.')
59
60 parser.add_option('--cold-load-percent', type='int', default=50,
61 help='%d of page visits for which a cold load is forced')
62
63 @classmethod
64 def ProcessCommandLineArgs(cls, parser, args):
65 cls._record_v8_object_stats = args.v8_object_stats
66 cls._report_speed_index = args.report_speed_index
67
68 cold_runs_percent_set = (args.cold_load_percent != None)
69 # Handle requests for cold cache runs 52 # Handle requests for cold cache runs
70 if (cold_runs_percent_set and 53 if (cold_runs_percent_set and
71 (args.cold_load_percent < 0 or args.cold_load_percent > 100)): 54 (cold_load_percent < 0 or cold_load_percent > 100)):
72 raise Exception('--cold-load-percent must be in the range [0-100]') 55 raise Exception('cold-load-percent must be in the range [0-100]')
73 56
74 # Make sure _cold_run_start_index is an integer multiple of page_repeat. 57 # Make sure _cold_run_start_index is an integer multiple of page_repeat.
75 # Without this, --pageset_shuffle + --page_repeat could lead to 58 # Without this, --pageset_shuffle + --page_repeat could lead to
76 # assertion failures on _started_warm in WillNavigateToPage. 59 # assertion failures on _started_warm in WillNavigateToPage.
77 if cold_runs_percent_set: 60 if cold_runs_percent_set:
78 number_warm_pageset_runs = int( 61 number_warm_pageset_runs = int(
79 (int(args.pageset_repeat) - 1) * (100 - args.cold_load_percent) / 100) 62 (int(pageset_repeat) - 1) * (100 - cold_load_percent) / 100)
80 number_warm_runs = number_warm_pageset_runs * args.page_repeat 63 number_warm_runs = number_warm_pageset_runs * page_repeat
81 cls._cold_run_start_index = number_warm_runs + args.page_repeat 64 self._cold_run_start_index = number_warm_runs + page_repeat
82 cls.discard_first_result = (not args.cold_load_percent or 65 self._discard_first_result = (not cold_load_percent or
83 cls.discard_first_result) 66 self._discard_first_result)
84 else: 67 else:
85 cls._cold_run_start_index = args.pageset_repeat * args.page_repeat 68 self._cold_run_start_index = pageset_repeat * page_repeat
86 69
87 def WillStartBrowser(self, platform): 70 def WillStartBrowser(self, platform):
88 """Initialize metrics once right before the browser has been launched.""" 71 """Initialize metrics once right before the browser has been launched."""
89 self._power_metric = power.PowerMetric(platform) 72 self._power_metric = power.PowerMetric(platform)
90 73
91 def DidStartBrowser(self, browser): 74 def DidStartBrowser(self, browser):
92 """Initialize metrics once right after the browser has been launched.""" 75 """Initialize metrics once right after the browser has been launched."""
93 self._memory_metric = memory.MemoryMetric(browser) 76 self._memory_metric = memory.MemoryMetric(browser)
94 self._cpu_metric = cpu.CpuMetric(browser) 77 self._cpu_metric = cpu.CpuMetric(browser)
95 if self._record_v8_object_stats: 78 if self._record_v8_object_stats:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 157
175 def ShouldRunCold(self, url): 158 def ShouldRunCold(self, url):
176 # We do the warm runs first for two reasons. The first is so we can 159 # 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. 160 # 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 161 # 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 162 # 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 163 # 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 164 # warm run, and clearing the cache before the load of the following
182 # URL would eliminate the intended warmup for the previous URL. 165 # URL would eliminate the intended warmup for the previous URL.
183 return (self._has_loaded_page[url] >= self._cold_run_start_index) 166 return (self._has_loaded_page[url] >= self._cold_run_start_index)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698