Chromium Code Reviews| 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 import os | 5 import os |
| 6 import tempfile | 6 import tempfile |
| 7 | 7 |
| 8 from measurements import session_restore | 8 from measurements import session_restore |
| 9 import page_sets | 9 import page_sets |
| 10 from profile_creators import small_profile_creator | 10 from profile_creators import small_profile_creator |
| 11 from telemetry import benchmark | 11 from telemetry import benchmark |
| 12 from telemetry.page import profile_generator | 12 from telemetry.page import profile_generator |
| 13 | 13 |
| 14 | 14 |
| 15 class _SessionRestoreTest(benchmark.Benchmark): | 15 class _SessionRestoreTest(benchmark.Benchmark): |
| 16 """Create a session restore test that is either "warm" or "cold". | |
|
qyearsley
2015/01/28 19:39:08
1. Possible alternative phrasing: "Base Benchmark
slamm
2015/02/23 23:46:35
Done.
| |
| 17 | |
| 18 Use Typical25PageSet to match what the SmallProfileCreator uses. | |
| 19 TODO(slamm): Make SmallProfileCreator and this use the same page_set ref. | |
| 20 """ | |
| 21 page_set = page_sets.Typical25PageSet | |
| 16 | 22 |
| 17 @classmethod | 23 @classmethod |
| 18 def ProcessCommandLineArgs(cls, parser, args): | 24 def ProcessCommandLineArgs(cls, parser, args): |
| 19 super(_SessionRestoreTest, cls).ProcessCommandLineArgs(parser, args) | 25 super(_SessionRestoreTest, cls).ProcessCommandLineArgs(parser, args) |
| 20 profile_type = 'small_profile' | 26 profile_type = 'small_profile' |
| 21 if not args.browser_options.profile_dir: | 27 if not args.browser_options.profile_dir: |
| 22 output_dir = os.path.join(tempfile.gettempdir(), profile_type) | 28 output_dir = os.path.join(tempfile.gettempdir(), profile_type) |
| 23 profile_dir = os.path.join(output_dir, profile_type) | 29 profile_dir = os.path.join(output_dir, profile_type) |
| 24 if not os.path.exists(output_dir): | 30 if not os.path.exists(output_dir): |
| 25 os.makedirs(output_dir) | 31 os.makedirs(output_dir) |
| 26 | 32 |
| 27 # Generate new profiles if profile_dir does not exist. It only exists if | 33 # Generate new profiles if profile_dir does not exist. It only exists if |
| 28 # all profiles had been correctly generated in a previous run. | 34 # all profiles had been correctly generated in a previous run. |
| 29 if not os.path.exists(profile_dir): | 35 if not os.path.exists(profile_dir): |
| 30 new_args = args.Copy() | 36 new_args = args.Copy() |
| 31 new_args.pageset_repeat = 1 | 37 new_args.pageset_repeat = 1 |
| 32 new_args.output_dir = output_dir | 38 new_args.output_dir = output_dir |
| 33 profile_generator.GenerateProfiles( | 39 profile_generator.GenerateProfiles( |
| 34 small_profile_creator.SmallProfileCreator, profile_type, new_args) | 40 small_profile_creator.SmallProfileCreator, profile_type, new_args) |
| 35 args.browser_options.profile_dir = profile_dir | 41 args.browser_options.profile_dir = profile_dir |
| 36 | 42 |
| 43 def CreateUserStorySet(self, _): | |
| 44 """Return a user story set that only has the first user story. | |
| 45 | |
| 46 The session restore measurement skips the navigation step and | |
| 47 only tests session restore by having the browser start-up. | |
| 48 The first user story is used to get WPR set up and hold results. | |
| 49 """ | |
| 50 user_story_set = self.page_set() | |
| 51 for user_story in user_story_set.user_stories[1:]: | |
| 52 user_story_set.RemoveUserStory(user_story) | |
| 53 return user_story_set | |
| 54 | |
| 37 def CreatePageTest(self, options): | 55 def CreatePageTest(self, options): |
| 38 is_cold = (self.tag == 'cold') | 56 is_cold = (self.tag == 'cold') |
| 39 return session_restore.SessionRestore(cold=is_cold) | 57 return session_restore.SessionRestore(cold=is_cold) |
| 40 | 58 |
| 41 # crbug.com/325479, crbug.com/381990 | 59 # crbug.com/325479, crbug.com/381990 |
| 42 @benchmark.Disabled('android', 'linux', 'reference') | 60 @benchmark.Disabled('android', 'linux', 'reference') |
| 43 class SessionRestoreColdTypical25(_SessionRestoreTest): | 61 class SessionRestoreColdTypical25(_SessionRestoreTest): |
| 44 tag = 'cold' | 62 tag = 'cold' |
| 45 page_set = page_sets.Typical25PageSet | |
| 46 options = {'pageset_repeat': 5} | 63 options = {'pageset_repeat': 5} |
| 47 | 64 |
| 48 | 65 |
| 49 # crbug.com/325479, crbug.com/381990 | 66 # crbug.com/325479, crbug.com/381990 |
| 50 @benchmark.Disabled('android', 'linux', 'reference') | 67 @benchmark.Disabled('android', 'linux', 'reference') |
| 51 class SessionRestoreWarmTypical25(_SessionRestoreTest): | 68 class SessionRestoreWarmTypical25(_SessionRestoreTest): |
| 52 tag = 'warm' | 69 tag = 'warm' |
| 53 page_set = page_sets.Typical25PageSet | |
| 54 options = {'pageset_repeat': 20} | 70 options = {'pageset_repeat': 20} |
| OLD | NEW |