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

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

Issue 714273004: mac: Expose keychain access frequency to Telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mock_keychain_sleep
Patch Set: Add a common subclass to measurements. 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
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 collections 18 import collections
19 import os 19 import os
20 20
21 from measurements import PageTestMeasurement
21 from metrics import cpu 22 from metrics import cpu
22 from metrics import iometric 23 from metrics import iometric
23 from metrics import memory 24 from metrics import memory
24 from metrics import power 25 from metrics import power
25 from metrics import speedindex 26 from metrics import speedindex
26 from metrics import v8_object_stats 27 from metrics import v8_object_stats
27 from telemetry.core import util 28 from telemetry.core import util
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(PageTestMeasurement):
33 options = {'pageset_repeat': 10} 33 options = {'pageset_repeat': 10}
34 34
35 def __init__(self, *args, **kwargs): 35 def __init__(self, *args, **kwargs):
36 super(PageCycler, self).__init__(*args, **kwargs) 36 super(PageCycler, self).__init__(*args, **kwargs)
37 37
38 with open(os.path.join(os.path.dirname(__file__), 38 with open(os.path.join(os.path.dirname(__file__),
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()
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 self._speedindex_metric.Start(page, tab) 111 self._speedindex_metric.Start(page, tab)
112 self._cpu_metric.Start(page, tab) 112 self._cpu_metric.Start(page, tab)
113 self._power_metric.Start(page, tab) 113 self._power_metric.Start(page, tab)
114 114
115 def DidNavigateToPage(self, page, tab): 115 def DidNavigateToPage(self, page, tab):
116 self._memory_metric.Start(page, tab) 116 self._memory_metric.Start(page, tab)
117 if self._record_v8_object_stats: 117 if self._record_v8_object_stats:
118 self._v8_object_stats_metric.Start(page, tab) 118 self._v8_object_stats_metric.Start(page, tab)
119 119
120 def CustomizeBrowserOptions(self, options): 120 def CustomizeBrowserOptions(self, options):
121 super(PageCycler, self).CustomizeBrowserOptions(options)
121 memory.MemoryMetric.CustomizeBrowserOptions(options) 122 memory.MemoryMetric.CustomizeBrowserOptions(options)
122 power.PowerMetric.CustomizeBrowserOptions(options) 123 power.PowerMetric.CustomizeBrowserOptions(options)
123 iometric.IOMetric.CustomizeBrowserOptions(options) 124 iometric.IOMetric.CustomizeBrowserOptions(options)
124 options.AppendExtraBrowserArgs('--js-flags=--expose_gc') 125 options.AppendExtraBrowserArgs('--js-flags=--expose_gc')
125 126
126 if self._record_v8_object_stats: 127 if self._record_v8_object_stats:
127 v8_object_stats.V8ObjectStatsMetric.CustomizeBrowserOptions(options) 128 v8_object_stats.V8ObjectStatsMetric.CustomizeBrowserOptions(options)
128 if self._report_speed_index: 129 if self._report_speed_index:
129 self._speedindex_metric.CustomizeBrowserOptions(options) 130 self._speedindex_metric.CustomizeBrowserOptions(options)
130 131
131 def ValidateAndMeasurePage(self, page, tab, results): 132 def ValidateAndMeasurePage(self, page, tab, results):
133 super(PageCycler, self).ValidateAndMeasurePage(page, tab, results)
132 tab.WaitForJavaScriptExpression('__pc_load_time', 60) 134 tab.WaitForJavaScriptExpression('__pc_load_time', 60)
133 135
134 chart_name_prefix = ('cold_' if self.IsRunCold(page.url) else 136 chart_name_prefix = ('cold_' if self.IsRunCold(page.url) else
135 'warm_') 137 'warm_')
136 138
137 results.AddValue(scalar.ScalarValue( 139 results.AddValue(scalar.ScalarValue(
138 results.current_page, '%stimes.page_load_time' % chart_name_prefix, 140 results.current_page, '%stimes.page_load_time' % chart_name_prefix,
139 'ms', tab.EvaluateJavaScript('__pc_load_time'), 141 'ms', tab.EvaluateJavaScript('__pc_load_time'),
140 description='Average page load time. Measured from ' 142 description='Average page load time. Measured from '
141 'performance.timing.navigationStart until the completion ' 143 'performance.timing.navigationStart until the completion '
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 176
175 def ShouldRunCold(self, url): 177 def ShouldRunCold(self, url):
176 # We do the warm runs first for two reasons. The first is so we can 178 # 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. 179 # 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 180 # 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 181 # 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 182 # 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 183 # warm run, and clearing the cache before the load of the following
182 # URL would eliminate the intended warmup for the previous URL. 184 # URL would eliminate the intended warmup for the previous URL.
183 return (self._has_loaded_page[url] >= self._cold_run_start_index) 185 return (self._has_loaded_page[url] >= self._cold_run_start_index)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698