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 |
28 @classmethod | |
29 def ProcessCommandLineArgs(cls, parser, args): | |
30 if not args.profile_dir: | |
31 logging.critical( | |
32 '--profile-dir or --profile-type is required for a session restore.\n' | |
33 'For more information see: http://goo.gl/ngdGD5') | |
34 sys.exit(1) | |
dtu
2014/06/04 22:05:00
parser.error(message)
| |
35 | |
24 def CustomizeBrowserOptions(self, options): | 36 def CustomizeBrowserOptions(self, options): |
25 super(SessionRestore, self).CustomizeBrowserOptions(options) | 37 super(SessionRestore, self).CustomizeBrowserOptions(options) |
26 options.AppendExtraBrowserArgs([ | 38 options.AppendExtraBrowserArgs([ |
27 '--restore-last-session' | 39 '--restore-last-session' |
28 ]) | 40 ]) |
29 | 41 |
30 def TabForPage(self, page, browser): | 42 def TabForPage(self, page, browser): |
31 # Detect that the session restore has completed. | 43 # Detect that the session restore has completed. |
32 util.WaitFor(lambda: len(browser.tabs), 30) | 44 util.WaitFor(lambda: len(browser.tabs), 30) |
33 return browser.tabs[0] | 45 return browser.tabs[0] |
(...skipping 27 matching lines...) Expand all Loading... | |
61 def MeasurePage(self, page, tab, results): | 73 def MeasurePage(self, page, tab, results): |
62 tab.browser.foreground_tab.WaitForDocumentReadyStateToBeComplete() | 74 tab.browser.foreground_tab.WaitForDocumentReadyStateToBeComplete() |
63 | 75 |
64 # Record CPU usage from browser start to when the foreground page is loaded. | 76 # Record CPU usage from browser start to when the foreground page is loaded. |
65 self._cpu_metric.Stop(None, None) | 77 self._cpu_metric.Stop(None, None) |
66 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') | 78 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') |
67 | 79 |
68 startup_metric.StartupMetric().AddResults(tab, results) | 80 startup_metric.StartupMetric().AddResults(tab, results) |
69 | 81 |
70 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. | 82 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. |
OLD | NEW |