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