OLD | NEW |
| (Empty) |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 import json | |
6 | |
7 from telemetry.page import page_measurement | |
8 | |
9 | |
10 class StartupWarm(page_measurement.PageMeasurement): | |
11 """Test how long Chrome takes to load when warm.""" | |
12 HISTOGRAMS_TO_RECORD = { | |
13 'messageloop_start_time' : | |
14 'Startup.BrowserMessageLoopStartTimeFromMainEntry', | |
15 'window_display_time' : 'Startup.BrowserWindowDisplay', | |
16 'open_tabs_time' : 'Startup.BrowserOpenTabs'} | |
17 | |
18 def __init__(self): | |
19 super(StartupWarm, self).__init__(needs_browser_restart_after_each_run=True, | |
20 discard_first_result=True) | |
21 | |
22 def CustomizeBrowserOptions(self, options): | |
23 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') | |
24 | |
25 # Old commandline flags used for reference builds. | |
26 options.AppendExtraBrowserArg('--dom-automation') | |
27 options.AppendExtraBrowserArg( | |
28 '--reduce-security-for-dom-automation-tests') | |
29 | |
30 def MeasurePage(self, page, tab, results): | |
31 # TODO(jeremy): Remove references to | |
32 # domAutomationController.getBrowserHistogram when we update the reference | |
33 # builds. | |
34 get_histogram_js = ('(window.statsCollectionController ?' | |
35 'statsCollectionController :' | |
36 'domAutomationController).getBrowserHistogram("%s")') | |
37 | |
38 | |
39 for display_name, histogram_name in self.HISTOGRAMS_TO_RECORD.iteritems(): | |
40 result = tab.EvaluateJavaScript(get_histogram_js % histogram_name) | |
41 result = json.loads(result) | |
42 measured_time = 0 | |
43 | |
44 if 'sum' in result: | |
45 # For all the histograms logged here, there's a single entry so sum | |
46 # is the exact value for that entry. | |
47 measured_time = result['sum'] | |
48 elif 'buckets' in result: | |
49 measured_time = \ | |
50 (result['buckets'][0]['high'] + result['buckets'][0]['low']) / 2 | |
51 | |
52 results.Add(display_name, 'ms', measured_time) | |
OLD | NEW |