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

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

Issue 22492004: Move memory-related histogram data collection to metrics/memory.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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 metrics import histogram
7 from telemetry.page import page_measurement 8 from telemetry.page import page_measurement
8 9
10 _HISTOGRAMS = {
11 'messageloop_start_time' :
12 'Startup.BrowserMessageLoopStartTimeFromMainEntry',
13 'window_display_time' : 'Startup.BrowserWindowDisplay',
14 'open_tabs_time' : 'Startup.BrowserOpenTabs'}
9 15
10 class StartupWarm(page_measurement.PageMeasurement): 16 class StartupWarm(page_measurement.PageMeasurement):
11 """Test how long Chrome takes to load when warm.""" 17 """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
18 def __init__(self): 19 def __init__(self):
19 super(StartupWarm, self).__init__(needs_browser_restart_after_each_run=True, 20 super(StartupWarm, self).__init__(needs_browser_restart_after_each_run=True,
20 discard_first_result=True) 21 discard_first_result=True)
21 22
22 def CustomizeBrowserOptions(self, options): 23 def CustomizeBrowserOptions(self, options):
23 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') 24 options.AppendExtraBrowserArg('--enable-stats-collection-bindings')
24 25
25 # Old commandline flags used for reference builds. 26 # Old commandline flags used for reference builds.
26 options.AppendExtraBrowserArg('--dom-automation') 27 options.AppendExtraBrowserArg('--dom-automation')
27 options.AppendExtraBrowserArg( 28 options.AppendExtraBrowserArg(
28 '--reduce-security-for-dom-automation-tests') 29 '--reduce-security-for-dom-automation-tests')
29 30
30 def MeasurePage(self, page, tab, results): 31 def MeasurePage(self, page, tab, results):
31 # TODO(jeremy): Remove references to 32 for display_name, histogram_name in _HISTOGRAMS.iteritems():
32 # domAutomationController.getBrowserHistogram when we update the reference 33 histogram_data = json.loads(histogram.GetHistogramData(
33 # builds. 34 histogram.BROWSER_HISTOGRAM, histogram_name, tab))
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 35 measured_time = 0
43 36
44 if 'sum' in result: 37 if 'sum' in histogram:
45 # For all the histograms logged here, there's a single entry so sum 38 # For all the histograms logged here, there's a single entry so sum
46 # is the exact value for that entry. 39 # is the exact value for that entry.
47 measured_time = result['sum'] 40 measured_time = histogram_data['sum']
48 elif 'buckets' in result: 41 elif 'buckets' in histogram_data:
49 measured_time = \ 42 measured_time = ((histogram_data['buckets'][0]['high'] +
50 (result['buckets'][0]['high'] + result['buckets'][0]['low']) / 2 43 histogram_data['buckets'][0]['low']) / 2)
51 44
52 results.Add(display_name, 'ms', measured_time) 45 results.Add(display_name, 'ms', measured_time)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698