OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Handles generating profiles and transferring them to/from mobile devices.""" | 5 """Handles generating profiles and transferring them to/from mobile devices.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
11 import stat | 11 import stat |
12 import sys | 12 import sys |
13 import tempfile | 13 import tempfile |
14 | 14 |
| 15 from telemetry import benchmark |
15 from telemetry.core import browser_options | 16 from telemetry.core import browser_options |
16 from telemetry.core import discover | 17 from telemetry.core import discover |
17 from telemetry.core import util | 18 from telemetry.core import util |
18 from telemetry.page import page_runner | 19 from telemetry.page import page_runner |
19 from telemetry.page import profile_creator | 20 from telemetry.page import profile_creator |
20 from telemetry.page import test_expectations | 21 from telemetry.page import test_expectations |
| 22 from telemetry.results import results_options |
21 | 23 |
22 | 24 |
23 def _DiscoverProfileCreatorClasses(): | 25 def _DiscoverProfileCreatorClasses(): |
24 profile_creators_dir = os.path.abspath(os.path.join(util.GetBaseDir(), | 26 profile_creators_dir = os.path.abspath(os.path.join(util.GetBaseDir(), |
25 os.pardir, 'perf', 'profile_creators')) | 27 os.pardir, 'perf', 'profile_creators')) |
26 base_dir = os.path.abspath(os.path.join(profile_creators_dir, os.pardir)) | 28 base_dir = os.path.abspath(os.path.join(profile_creators_dir, os.pardir)) |
27 | 29 |
28 profile_creators_unfiltered = discover.DiscoverClasses( | 30 profile_creators_unfiltered = discover.DiscoverClasses( |
29 profile_creators_dir, base_dir, profile_creator.ProfileCreator) | 31 profile_creators_dir, base_dir, profile_creator.ProfileCreator) |
30 | 32 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 return ignore_list | 67 return ignore_list |
66 | 68 |
67 def GenerateProfiles(profile_creator_class, profile_creator_name, options): | 69 def GenerateProfiles(profile_creator_class, profile_creator_name, options): |
68 """Generate a profile""" | 70 """Generate a profile""" |
69 expectations = test_expectations.TestExpectations() | 71 expectations = test_expectations.TestExpectations() |
70 test = profile_creator_class() | 72 test = profile_creator_class() |
71 | 73 |
72 temp_output_directory = tempfile.mkdtemp() | 74 temp_output_directory = tempfile.mkdtemp() |
73 options.output_profile_path = temp_output_directory | 75 options.output_profile_path = temp_output_directory |
74 | 76 |
75 results = page_runner.Run(test, test.page_set, expectations, options) | 77 results = results_options.CreateResults( |
| 78 benchmark.BenchmarkMetadata(test.__class__.__name__), options) |
| 79 page_runner.Run(test, test.page_set, expectations, options, results) |
76 | 80 |
77 if results.failures: | 81 if results.failures: |
78 logging.warning('Some pages failed.') | 82 logging.warning('Some pages failed.') |
79 logging.warning('Failed pages:\n%s', | 83 logging.warning('Failed pages:\n%s', |
80 '\n'.join(results.pages_that_failed)) | 84 '\n'.join(results.pages_that_failed)) |
81 return 1 | 85 return 1 |
82 | 86 |
83 # Everything is a-ok, move results to final destination. | 87 # Everything is a-ok, move results to final destination. |
84 generated_profiles_dir = os.path.abspath(options.output_dir) | 88 generated_profiles_dir = os.path.abspath(options.output_dir) |
85 if not os.path.exists(generated_profiles_dir): | 89 if not os.path.exists(generated_profiles_dir): |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 "%%prog <--profile-type-to-generate=...> <--browser=...> <--output-dir>") | 144 "%%prog <--profile-type-to-generate=...> <--browser=...> <--output-dir>") |
141 AddCommandLineArgs(parser) | 145 AddCommandLineArgs(parser) |
142 _, _ = parser.parse_args() | 146 _, _ = parser.parse_args() |
143 ProcessCommandLineArgs(parser, options) | 147 ProcessCommandLineArgs(parser, options) |
144 | 148 |
145 # Generate profile. | 149 # Generate profile. |
146 profile_creators = _DiscoverProfileCreatorClasses() | 150 profile_creators = _DiscoverProfileCreatorClasses() |
147 profile_creator_class = profile_creators[options.profile_type_to_generate] | 151 profile_creator_class = profile_creators[options.profile_type_to_generate] |
148 return GenerateProfiles(profile_creator_class, | 152 return GenerateProfiles(profile_creator_class, |
149 options.profile_type_to_generate, options) | 153 options.profile_type_to_generate, options) |
OLD | NEW |