OLD | NEW |
---|---|
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 |
6 import logging | |
7 import sys | |
5 | 8 |
6 from measurements import startup | 9 from measurements import startup |
7 from metrics import cpu | 10 from metrics import cpu |
8 from metrics import startup_metric | 11 from metrics import startup_metric |
9 from telemetry.core import util | 12 from telemetry.core import util |
10 | 13 |
14 | |
11 class SessionRestore(startup.Startup): | 15 class SessionRestore(startup.Startup): |
12 """Performs a measurement of Chromium's Session restore performance. | 16 """Performs a measurement of Chromium's Session restore performance. |
13 | 17 |
14 This test is meant to be run against a generated profile. | 18 This test is meant to be run against a generated profile. |
15 This test inherits support for the --warm or --cold command line options - | 19 This test inherits support for the --warm or --cold command line options - |
16 see startup.py for details. | 20 see startup.py for details. |
17 """ | 21 """ |
18 | 22 |
19 def __init__(self, action_name_to_run = ''): | 23 def __init__(self, action_name_to_run = ''): |
20 super(SessionRestore, self).__init__(action_name_to_run=action_name_to_run) | 24 super(SessionRestore, self).__init__(action_name_to_run=action_name_to_run) |
21 self.close_tabs_before_run = False | 25 self.close_tabs_before_run = False |
22 self._cpu_metric = None | 26 self._cpu_metric = None |
23 | 27 |
24 def CustomizeBrowserOptions(self, options): | 28 def CustomizeBrowserOptions(self, options): |
25 super(SessionRestore, self).CustomizeBrowserOptions(options) | 29 super(SessionRestore, self).CustomizeBrowserOptions(options) |
26 options.AppendExtraBrowserArgs([ | 30 options.AppendExtraBrowserArgs([ |
27 '--restore-last-session' | 31 '--restore-last-session' |
28 ]) | 32 ]) |
33 if not options.profile_dir: | |
dtu
2014/06/05 01:35:28
Goes into ProcessCommandLineArgs still
| |
34 logging.critical( | |
35 '--profile-dir or --profile-type is required for a session restore.\n' | |
36 'For more information see: http://goo.gl/ngdGD5') | |
37 sys.exit(1) | |
29 | 38 |
30 def TabForPage(self, page, browser): | 39 def TabForPage(self, page, browser): |
31 # Detect that the session restore has completed. | 40 # Detect that the session restore has completed. |
32 util.WaitFor(lambda: len(browser.tabs), 30) | 41 util.WaitFor(lambda: len(browser.tabs), 30) |
33 return browser.tabs[0] | 42 return browser.tabs[0] |
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 |
(...skipping 22 matching lines...) Expand all Loading... | |
61 def MeasurePage(self, page, tab, results): | 70 def MeasurePage(self, page, tab, results): |
62 tab.browser.foreground_tab.WaitForDocumentReadyStateToBeComplete() | 71 tab.browser.foreground_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. |
OLD | NEW |