| 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 _SessionRestoreTypical25(benchmark.Benchmark): |
| 16 """Base Benchmark class for session restore benchmarks. |
| 17 |
| 18 A cold start means none of the Chromium files are in the disk cache. |
| 19 A warm start assumes the OS has already cached much of Chromium's content. |
| 20 For warm tests, you should repeat the page set to ensure it's cached. |
| 21 |
| 22 Use Typical25PageSet to match what the SmallProfileCreator uses. |
| 23 TODO(slamm): Make SmallProfileCreator and this use the same page_set ref. |
| 24 """ |
| 25 page_set = page_sets.Typical25PageSet |
| 16 | 26 |
| 17 @classmethod | 27 @classmethod |
| 18 def Name(cls): | 28 def Name(cls): |
| 19 return 'session_restore' | 29 return 'session_restore' |
| 20 | 30 |
| 21 @classmethod | 31 @classmethod |
| 22 def ProcessCommandLineArgs(cls, parser, args): | 32 def ProcessCommandLineArgs(cls, parser, args): |
| 23 super(_SessionRestoreTest, cls).ProcessCommandLineArgs(parser, args) | 33 super(_SessionRestoreTypical25, cls).ProcessCommandLineArgs(parser, args) |
| 24 profile_type = 'small_profile' | 34 profile_type = 'small_profile' |
| 25 if not args.browser_options.profile_dir: | 35 if not args.browser_options.profile_dir: |
| 26 output_dir = os.path.join(tempfile.gettempdir(), profile_type) | 36 output_dir = os.path.join(tempfile.gettempdir(), profile_type) |
| 27 profile_dir = os.path.join(output_dir, profile_type) | 37 profile_dir = os.path.join(output_dir, profile_type) |
| 28 if not os.path.exists(output_dir): | 38 if not os.path.exists(output_dir): |
| 29 os.makedirs(output_dir) | 39 os.makedirs(output_dir) |
| 30 | 40 |
| 31 # Generate new profiles if profile_dir does not exist. It only exists if | 41 # Generate new profiles if profile_dir does not exist. It only exists if |
| 32 # all profiles had been correctly generated in a previous run. | 42 # all profiles had been correctly generated in a previous run. |
| 33 if not os.path.exists(profile_dir): | 43 if not os.path.exists(profile_dir): |
| 34 new_args = args.Copy() | 44 new_args = args.Copy() |
| 35 new_args.pageset_repeat = 1 | 45 new_args.pageset_repeat = 1 |
| 36 new_args.output_dir = output_dir | 46 new_args.output_dir = output_dir |
| 37 profile_generator.GenerateProfiles( | 47 profile_generator.GenerateProfiles( |
| 38 small_profile_creator.SmallProfileCreator, profile_type, new_args) | 48 small_profile_creator.SmallProfileCreator, profile_type, new_args) |
| 39 args.browser_options.profile_dir = profile_dir | 49 args.browser_options.profile_dir = profile_dir |
| 40 | 50 |
| 51 def CreateUserStorySet(self, _): |
| 52 """Return a user story set that only has the first user story. |
| 53 |
| 54 The session restore measurement skips the navigation step and |
| 55 only tests session restore by having the browser start-up. |
| 56 The first user story is used to get WPR set up and hold results. |
| 57 """ |
| 58 user_story_set = self.page_set() |
| 59 for user_story in user_story_set.user_stories[1:]: |
| 60 user_story_set.RemoveUserStory(user_story) |
| 61 return user_story_set |
| 62 |
| 41 def CreatePageTest(self, options): | 63 def CreatePageTest(self, options): |
| 42 is_cold = (self.tag == 'cold') | 64 is_cold = (self.tag == 'cold') |
| 43 return session_restore.SessionRestore(cold=is_cold) | 65 return session_restore.SessionRestore(cold=is_cold) |
| 44 | 66 |
| 45 def CreatePageSet(self, options): | 67 def CreatePageSet(self, options): |
| 46 return page_sets.Typical25PageSet(run_no_page_interactions=True) | 68 return page_sets.Typical25PageSet(run_no_page_interactions=True) |
| 47 | 69 |
| 48 # crbug.com/325479, crbug.com/381990 | 70 # crbug.com/325479, crbug.com/381990 |
| 49 @benchmark.Disabled('android', 'linux', 'reference') | 71 @benchmark.Disabled('android', 'linux', 'reference') |
| 50 class SessionRestoreColdTypical25(_SessionRestoreTest): | 72 class SessionRestoreColdTypical25(_SessionRestoreTypical25): |
| 73 """Test by clearing system cache and profile before repeats.""" |
| 51 tag = 'cold' | 74 tag = 'cold' |
| 52 options = {'pageset_repeat': 5} | 75 options = {'pageset_repeat': 5} |
| 53 | 76 |
| 54 @classmethod | 77 @classmethod |
| 55 def Name(cls): | 78 def Name(cls): |
| 56 return 'session_restore.cold.typical_25' | 79 return 'session_restore.cold.typical_25' |
| 57 | 80 |
| 58 | 81 |
| 59 # crbug.com/325479, crbug.com/381990 | 82 # crbug.com/325479, crbug.com/381990 |
| 60 @benchmark.Disabled('android', 'linux', 'reference') | 83 @benchmark.Disabled('android', 'linux', 'reference') |
| 61 class SessionRestoreWarmTypical25(_SessionRestoreTest): | 84 class SessionRestoreWarmTypical25(_SessionRestoreTypical25): |
| 85 """Test without clearing system cache or profile before repeats. |
| 86 |
| 87 The first result is discarded. |
| 88 """ |
| 62 tag = 'warm' | 89 tag = 'warm' |
| 63 options = {'pageset_repeat': 20} | 90 options = {'pageset_repeat': 20} |
| 64 | 91 |
| 65 @classmethod | 92 @classmethod |
| 66 def Name(cls): | 93 def Name(cls): |
| 67 return 'session_restore.warm.typical_25' | 94 return 'session_restore.warm.typical_25' |
| 68 | 95 |
| OLD | NEW |