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

Side by Side Diff: tools/perf/metrics/startup_metric.py

Issue 379233002: Update startup_metric to use results.AddValue(...) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 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 import collections 4 import collections
5 import json 5 import json
6 import logging 6 import logging
7 7
8 from metrics import Metric 8 from metrics import Metric
9 from metrics import histogram_util 9 from metrics import histogram_util
10 10
11 from telemetry.core import util 11 from telemetry.core import util
12 from telemetry.value import scalar
12 13
13 14
14 class StartupMetric(Metric): 15 class StartupMetric(Metric):
15 "A metric for browser startup time." 16 "A metric for browser startup time."
16 17
17 HISTOGRAMS_TO_RECORD = { 18 HISTOGRAMS_TO_RECORD = {
18 'messageloop_start_time' : 19 'messageloop_start_time' :
19 'Startup.BrowserMessageLoopStartTimeFromMainEntry', 20 'Startup.BrowserMessageLoopStartTimeFromMainEntry',
20 'window_display_time' : 'Startup.BrowserWindowDisplay', 21 'window_display_time' : 'Startup.BrowserWindowDisplay',
21 'open_tabs_time' : 'Startup.BrowserOpenTabs'} 22 'open_tabs_time' : 'Startup.BrowserOpenTabs'}
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 # because on Android the data of the background tabs is loaded on demand, 78 # because on Android the data of the background tabs is loaded on demand,
78 # when the user switches to them, rather than during startup. In view of 79 # when the user switches to them, rather than during startup. In view of
79 # this, to get the same measures on all platform, we only measure the 80 # this, to get the same measures on all platform, we only measure the
80 # foreground tab on all platforms. 81 # foreground tab on all platforms.
81 82
82 RecordTabLoadTime(tab.browser.foreground_tab) 83 RecordTabLoadTime(tab.browser.foreground_tab)
83 84
84 foreground_tab_stats = tab_load_times[0] 85 foreground_tab_stats = tab_load_times[0]
85 foreground_tab_load_complete = ((foreground_tab_stats.load_start_ms + 86 foreground_tab_load_complete = ((foreground_tab_stats.load_start_ms +
86 foreground_tab_stats.load_duration_ms) - browser_main_entry_time_ms) 87 foreground_tab_stats.load_duration_ms) - browser_main_entry_time_ms)
87 results.Add( 88 results.AddValue(scalar.ScalarValue(
88 'foreground_tab_load_complete', 'ms', foreground_tab_load_complete) 89 results.current_page, 'foreground_tab_load_complete', 'ms',
90 foreground_tab_load_complete))
89 91
90 def AddResults(self, tab, results): 92 def AddResults(self, tab, results):
91 get_histogram_js = 'statsCollectionController.getBrowserHistogram("%s")' 93 get_histogram_js = 'statsCollectionController.getBrowserHistogram("%s")'
92 94
93 for display_name, histogram_name in self.HISTOGRAMS_TO_RECORD.iteritems(): 95 for display_name, histogram_name in self.HISTOGRAMS_TO_RECORD.iteritems():
94 result = tab.EvaluateJavaScript(get_histogram_js % histogram_name) 96 result = tab.EvaluateJavaScript(get_histogram_js % histogram_name)
95 result = json.loads(result) 97 result = json.loads(result)
96 measured_time = 0 98 measured_time = 0
97 99
98 if 'sum' in result: 100 if 'sum' in result:
99 # For all the histograms logged here, there's a single entry so sum 101 # For all the histograms logged here, there's a single entry so sum
100 # is the exact value for that entry. 102 # is the exact value for that entry.
101 measured_time = result['sum'] 103 measured_time = result['sum']
102 elif 'buckets' in result: 104 elif 'buckets' in result:
103 measured_time = \ 105 measured_time = \
104 (result['buckets'][0]['high'] + result['buckets'][0]['low']) / 2 106 (result['buckets'][0]['high'] + result['buckets'][0]['low']) / 2
105 107
106 results.Add(display_name, 'ms', measured_time) 108 results.AddValue(scalar.ScalarValue(
109 results.current_page, display_name, 'ms', measured_time))
107 110
108 # Get tab load times. 111 # Get tab load times.
109 browser_main_entry_time_ms = self._GetBrowserMainEntryTime(tab) 112 browser_main_entry_time_ms = self._GetBrowserMainEntryTime(tab)
110 if (browser_main_entry_time_ms is None): 113 if (browser_main_entry_time_ms is None):
111 print "Outdated Chrome version, browser main entry time not supported." 114 print "Outdated Chrome version, browser main entry time not supported."
112 return 115 return
113 self._RecordTabLoadTimes(tab, browser_main_entry_time_ms, results) 116 self._RecordTabLoadTimes(tab, browser_main_entry_time_ms, results)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698