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

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

Issue 22300013: Add a Telemetry based cold startup test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 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 import json 5 import json
6 6
7 from telemetry.page import page_measurement 7 from telemetry.page import page_measurement
8 8
9 class StartupTest(page_measurement.PageMeasurement):
tonyg 2013/08/08 01:16:35 I think the precedent is to just call this "Startu
James Simonsen 2013/08/08 02:06:07 Done.
10 """Performs a measurement of Chromium's startup performance.
9 11
10 class StartupWarm(page_measurement.PageMeasurement): 12 This test must be invoked with either --warm or --cold on the command line. A
11 """Test how long Chrome takes to load when warm.""" 13 cold start means none of the Chromium files are in the disk cache. A warm
14 start assumes the OS has already cached much of Chromium's content. For warm
15 tests, you should repeat the page set to ensure it's cached.
16 """
17
12 HISTOGRAMS_TO_RECORD = { 18 HISTOGRAMS_TO_RECORD = {
13 'messageloop_start_time' : 19 'messageloop_start_time' :
14 'Startup.BrowserMessageLoopStartTimeFromMainEntry', 20 'Startup.BrowserMessageLoopStartTimeFromMainEntry',
15 'window_display_time' : 'Startup.BrowserWindowDisplay', 21 'window_display_time' : 'Startup.BrowserWindowDisplay',
16 'open_tabs_time' : 'Startup.BrowserOpenTabs'} 22 'open_tabs_time' : 'Startup.BrowserOpenTabs'}
17 23
18 def __init__(self): 24 def __init__(self):
19 super(StartupWarm, self).__init__(needs_browser_restart_after_each_run=True, 25 super(StartupTest, self).__init__(needs_browser_restart_after_each_run=True)
20 discard_first_result=True) 26 self._cold = False
27 self._warm = False
tonyg 2013/08/08 01:16:35 Let's use one bool so these can't get set improper
James Simonsen 2013/08/08 02:06:07 Done.
28
29 def AddCommandLineOptions(self, parser):
30 parser.add_option('--cold', action='store_true',
31 help='Clear the OS disk cache before performing the test')
32 parser.add_option('--warm', action='store_true',
33 help='Start up with everything already cached')
21 34
22 def CustomizeBrowserOptions(self, options): 35 def CustomizeBrowserOptions(self, options):
36 assert options.warm != options.cold, \
37 "You must specify either --warm or --cold"
38 self._cold = options.cold
39 self._warm = options.warm
40
41 if self._cold:
42 options.clear_sytem_cache_for_browser_and_profile_on_start = True
43
44 if self._warm:
45 self.discard_first_result = True
46
23 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') 47 options.AppendExtraBrowserArg('--enable-stats-collection-bindings')
24 48
25 # Old commandline flags used for reference builds. 49 # Old commandline flags used for reference builds.
26 options.AppendExtraBrowserArg('--dom-automation') 50 options.AppendExtraBrowserArg('--dom-automation')
27 options.AppendExtraBrowserArg( 51 options.AppendExtraBrowserArg(
28 '--reduce-security-for-dom-automation-tests') 52 '--reduce-security-for-dom-automation-tests')
29 53
30 def MeasurePage(self, page, tab, results): 54 def MeasurePage(self, page, tab, results):
31 # TODO(jeremy): Remove references to 55 # TODO(jeremy): Remove references to
32 # domAutomationController.getBrowserHistogram when we update the reference 56 # domAutomationController.getBrowserHistogram when we update the reference
33 # builds. 57 # builds.
34 get_histogram_js = ('(window.statsCollectionController ?' 58 get_histogram_js = ('(window.statsCollectionController ?'
35 'statsCollectionController :' 59 'statsCollectionController :'
36 'domAutomationController).getBrowserHistogram("%s")') 60 'domAutomationController).getBrowserHistogram("%s")')
37 61
38
39 for display_name, histogram_name in self.HISTOGRAMS_TO_RECORD.iteritems(): 62 for display_name, histogram_name in self.HISTOGRAMS_TO_RECORD.iteritems():
40 result = tab.EvaluateJavaScript(get_histogram_js % histogram_name) 63 result = tab.EvaluateJavaScript(get_histogram_js % histogram_name)
41 result = json.loads(result) 64 result = json.loads(result)
42 measured_time = 0 65 measured_time = 0
43 66
44 if 'sum' in result: 67 if 'sum' in result:
45 # For all the histograms logged here, there's a single entry so sum 68 # For all the histograms logged here, there's a single entry so sum
46 # is the exact value for that entry. 69 # is the exact value for that entry.
47 measured_time = result['sum'] 70 measured_time = result['sum']
48 elif 'buckets' in result: 71 elif 'buckets' in result:
49 measured_time = \ 72 measured_time = \
50 (result['buckets'][0]['high'] + result['buckets'][0]['low']) / 2 73 (result['buckets'][0]['high'] + result['buckets'][0]['low']) / 2
51 74
52 results.Add(display_name, 'ms', measured_time) 75 results.Add(display_name, 'ms', measured_time)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698