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 |
5 from metrics import startup_metric | 5 from metrics import startup_metric |
6 from telemetry.page import page_measurement | 6 from telemetry.page import page_measurement |
7 | 7 |
8 class Startup(page_measurement.PageMeasurement): | 8 class Startup(page_measurement.PageMeasurement): |
9 """Performs a measurement of Chromium's startup performance. | 9 """Performs a measurement of Chromium's startup performance. |
10 | 10 |
11 This test must be invoked with either --warm or --cold on the command line. A | 11 This test must be invoked with either --warm or --cold on the command line. A |
12 cold start means none of the Chromium files are in the disk cache. A warm | 12 cold start means none of the Chromium files are in the disk cache. A warm |
13 start assumes the OS has already cached much of Chromium's content. For warm | 13 start assumes the OS has already cached much of Chromium's content. For warm |
14 tests, you should repeat the page set to ensure it's cached. | 14 tests, you should repeat the page set to ensure it's cached. |
15 """ | 15 """ |
16 | 16 |
17 def __init__(self): | 17 def __init__(self, action_name_to_run = ''): |
18 super(Startup, self).__init__(needs_browser_restart_after_each_run=True, | 18 super(Startup, self).__init__(needs_browser_restart_after_each_run=True, |
19 action_name_to_run='navigate_steps') | 19 action_name_to_run=action_name_to_run) |
20 | 20 |
21 def AddCommandLineOptions(self, parser): | 21 def AddCommandLineOptions(self, parser): |
22 parser.add_option('--cold', action='store_true', | 22 parser.add_option('--cold', action='store_true', |
23 help='Clear the OS disk cache before performing the test') | 23 help='Clear the OS disk cache before performing the test') |
24 parser.add_option('--warm', action='store_true', | 24 parser.add_option('--warm', action='store_true', |
25 help='Start up with everything already cached') | 25 help='Start up with everything already cached') |
26 | 26 |
27 def CustomizeBrowserOptions(self, options): | 27 def CustomizeBrowserOptions(self, options): |
28 # TODO: Once the bots start running benchmarks, enforce that either --warm | 28 # TODO: Once the bots start running benchmarks, enforce that either --warm |
29 # or --cold is explicitly specified. | 29 # or --cold is explicitly specified. |
30 # assert options.warm != options.cold, \ | 30 # assert options.warm != options.cold, \ |
31 # "You must specify either --warm or --cold" | 31 # "You must specify either --warm or --cold" |
32 if options.cold: | 32 if options.cold: |
33 browser_options = options.browser_options | 33 browser_options = options.browser_options |
34 browser_options.clear_sytem_cache_for_browser_and_profile_on_start = True | 34 browser_options.clear_sytem_cache_for_browser_and_profile_on_start = True |
35 else: | 35 else: |
36 self.discard_first_result = True | 36 self.discard_first_result = True |
37 | 37 |
38 options.AppendExtraBrowserArgs([ | 38 options.AppendExtraBrowserArgs([ |
39 '--enable-stats-collection-bindings' | 39 '--enable-stats-collection-bindings' |
40 ]) | 40 ]) |
41 | 41 |
42 def RunNavigateSteps(self, page, tab): | 42 def RunNavigateSteps(self, page, tab): |
43 # Overriden so that no page navigation occurs - startup to the NTP. | 43 # Overriden so that no page navigation occurs - startup to the NTP. |
44 pass | 44 pass |
45 | 45 |
46 def MeasurePage(self, page, tab, results): | 46 def MeasurePage(self, page, tab, results): |
47 startup_metric.StartupMetric().AddResults(tab, results) | 47 startup_metric.StartupMetric().AddResults(tab, results) |
| 48 |
| 49 |
| 50 class StartWithUrl(Startup): |
| 51 """Performs a measurement of Chromium's performance starting with a URL. |
| 52 |
| 53 This test must be invoked with either --warm or --cold on the command line. A |
| 54 cold start means none of the Chromium files are in the disk cache. A warm |
| 55 start assumes the OS has already cached much of Chromium's content. For warm |
| 56 tests, you should repeat the page set to ensure it's cached. |
| 57 |
| 58 The startup URL is taken from the page set's set_startup_url action. This |
| 59 allows the testing of multiple different URLs in a single benchmark. |
| 60 """ |
| 61 |
| 62 def __init__(self): |
| 63 super(StartWithUrl, self).__init__(action_name_to_run='navigate_steps') |
OLD | NEW |