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

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

Issue 313923003: [Telemetry] Fix race in session restore measurement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
4 import collections 5 import collections
5 6
6 from measurements import startup 7 from measurements import startup
7 from metrics import cpu 8 from metrics import cpu
9 from metrics import histogram_util
8 from metrics import startup_metric 10 from metrics import startup_metric
9 from telemetry.core import util 11 from telemetry.core import util
10 12
13
11 class SessionRestore(startup.Startup): 14 class SessionRestore(startup.Startup):
12 """Performs a measurement of Chromium's Session restore performance. 15 """Performs a measurement of Chromium's Session restore performance.
13 16
14 This test is meant to be run against a generated profile. 17 This test is meant to be run against a generated profile.
15 This test inherits support for the --warm or --cold command line options - 18 This test inherits support for the --warm or --cold command line options -
16 see startup.py for details. 19 see startup.py for details.
17 """ 20 """
18 21
19 def __init__(self, action_name_to_run = ''): 22 def __init__(self, action_name_to_run = ''):
20 super(SessionRestore, self).__init__(action_name_to_run=action_name_to_run) 23 super(SessionRestore, self).__init__(action_name_to_run=action_name_to_run)
21 self.close_tabs_before_run = False 24 self.close_tabs_before_run = False
22 self._cpu_metric = None 25 self._cpu_metric = None
23 26
24 def CustomizeBrowserOptions(self, options): 27 def CustomizeBrowserOptions(self, options):
25 super(SessionRestore, self).CustomizeBrowserOptions(options) 28 super(SessionRestore, self).CustomizeBrowserOptions(options)
29 histogram_util.CustomizeBrowserOptions(options)
26 options.AppendExtraBrowserArgs([ 30 options.AppendExtraBrowserArgs([
27 '--restore-last-session' 31 '--restore-last-session'
28 ]) 32 ])
29 33
30 def TabForPage(self, page, browser): 34 def TabForPage(self, page, browser):
31 # Detect that the session restore has completed. 35 # Detect that the session restore has completed.
32 util.WaitFor(lambda: len(browser.tabs), 30) 36 util.WaitFor(lambda: browser.tabs and
33 return browser.tabs[0] 37 histogram_util.GetHistogramCount(
38 histogram_util.BROWSER_HISTOGRAM,
39 'SessionRestore.AllTabsLoaded',
40 browser.foreground_tab),
jeremy 2014/06/05 10:39:04 Very nice!!!
41 30)
42 return browser.foreground_tab
34 43
35 def CanRunForPage(self, page): 44 def CanRunForPage(self, page):
36 # No matter how many pages in the pageset, just perform one test iteration. 45 # No matter how many pages in the pageset, just perform one test iteration.
37 return page.page_set.pages.index(page) == 0 46 return page.page_set.pages.index(page) == 0
38 47
39 def RunNavigateSteps(self, page, tab): 48 def RunNavigateSteps(self, page, tab):
40 # Overriden so that no page navigation occurs. 49 # Overriden so that no page navigation occurs.
41 pass 50 pass
42 51
43 def ValidatePageSet(self, page_set): 52 def ValidatePageSet(self, page_set):
44 wpr_archive_names_to_page_urls = collections.defaultdict(list) 53 wpr_archive_names_to_page_urls = collections.defaultdict(list)
45 # Construct the map from pages' wpr archive names to pages' urls. 54 # Construct the map from pages' wpr archive names to pages' urls.
46 for page in page_set: 55 for page in page_set:
47 if page.is_local: 56 if page.is_local:
48 continue 57 continue
49 wpr_archive_name = page_set.WprFilePathForPage(page) 58 wpr_archive_name = page_set.WprFilePathForPage(page)
50 wpr_archive_names_to_page_urls[wpr_archive_name].append(page.url) 59 wpr_archive_names_to_page_urls[wpr_archive_name].append(page.url)
51 60
52 # Reject any pageset that contains more than one WPR archive. 61 # Reject any pageset that contains more than one WPR archive.
53 if len(wpr_archive_names_to_page_urls.keys()) > 1: 62 if len(wpr_archive_names_to_page_urls.keys()) > 1:
54 raise Exception("Invalid pageset: more than 1 WPR archive found.: " + 63 raise Exception("Invalid pageset: more than 1 WPR archive found.: " +
55 repr(wpr_archive_names_to_page_urls)) 64 repr(wpr_archive_names_to_page_urls))
56 65
57 def DidStartBrowser(self, browser): 66 def DidStartBrowser(self, browser):
58 self._cpu_metric = cpu.CpuMetric(browser) 67 self._cpu_metric = cpu.CpuMetric(browser)
59 self._cpu_metric.Start(None, None) 68 self._cpu_metric.Start(None, None)
60 69
61 def MeasurePage(self, page, tab, results): 70 def MeasurePage(self, page, tab, results):
62 tab.browser.foreground_tab.WaitForDocumentReadyStateToBeComplete() 71 tab.WaitForDocumentReadyStateToBeComplete()
63 72
64 # Record CPU usage from browser start to when the foreground page is loaded. 73 # Record CPU usage from browser start to when the foreground page is loaded.
65 self._cpu_metric.Stop(None, None) 74 self._cpu_metric.Stop(None, None)
66 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') 75 self._cpu_metric.AddResults(tab, results, 'cpu_utilization')
67 76
68 startup_metric.StartupMetric().AddResults(tab, results) 77 startup_metric.StartupMetric().AddResults(tab, results)
69 78
70 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. 79 # TODO(jeremy): Measure time to load - first, last and frontmost tab here.
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