| 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 _SessionRestoreTypical25(benchmark.Benchmark): | 15 class _SessionRestoreTypical25(benchmark.Benchmark): |
| 16 """Base Benchmark class for session restore benchmarks. | 16 """Base Benchmark class for session restore benchmarks. |
| 17 | 17 |
| 18 A cold start means none of the Chromium files are in the disk cache. | 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. | 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. | 20 For warm tests, you should repeat the page set to ensure it's cached. |
| 21 | 21 |
| 22 Use Typical25PageSet to match what the SmallProfileCreator uses. | 22 Use Typical25PageSet to match what the SmallProfileCreator uses. |
| 23 TODO(slamm): Make SmallProfileCreator and this use the same page_set ref. | 23 TODO(slamm): Make SmallProfileCreator and this use the same page_set ref. |
| 24 """ | 24 """ |
| 25 page_set = page_sets.Typical25PageSet | 25 page_set = page_sets.Typical25PageSet |
| 26 tag = None # subclasses set as 'warm' or 'cold' |
| 26 | 27 |
| 27 @classmethod | 28 @classmethod |
| 28 def Name(cls): | 29 def Name(cls): |
| 29 return 'session_restore' | 30 return 'session_restore' |
| 30 | 31 |
| 31 @classmethod | 32 @classmethod |
| 32 def ProcessCommandLineArgs(cls, parser, args): | 33 def ProcessCommandLineArgs(cls, parser, args): |
| 33 super(_SessionRestoreTypical25, cls).ProcessCommandLineArgs(parser, args) | 34 super(_SessionRestoreTypical25, cls).ProcessCommandLineArgs(parser, args) |
| 34 profile_type = 'small_profile' | 35 profile_type = 'small_profile' |
| 35 if not args.browser_options.profile_dir: | 36 if not args.browser_options.profile_dir: |
| 36 output_dir = os.path.join(tempfile.gettempdir(), profile_type) | 37 output_dir = os.path.join(tempfile.gettempdir(), profile_type) |
| 37 profile_dir = os.path.join(output_dir, profile_type) | 38 profile_dir = os.path.join(output_dir, profile_type) |
| 38 if not os.path.exists(output_dir): | 39 if not os.path.exists(output_dir): |
| 39 os.makedirs(output_dir) | 40 os.makedirs(output_dir) |
| 40 | 41 |
| 41 # Generate new profiles if profile_dir does not exist. It only exists if | 42 # Generate new profiles if profile_dir does not exist. It only exists if |
| 42 # all profiles had been correctly generated in a previous run. | 43 # all profiles had been correctly generated in a previous run. |
| 43 if not os.path.exists(profile_dir): | 44 if not os.path.exists(profile_dir): |
| 44 new_args = args.Copy() | 45 new_args = args.Copy() |
| 45 new_args.pageset_repeat = 1 | 46 new_args.pageset_repeat = 1 |
| 46 new_args.output_dir = output_dir | 47 new_args.output_dir = output_dir |
| 47 profile_generator.GenerateProfiles( | 48 profile_generator.GenerateProfiles( |
| 48 small_profile_creator.SmallProfileCreator, profile_type, new_args) | 49 small_profile_creator.SmallProfileCreator, profile_type, new_args) |
| 49 args.browser_options.profile_dir = profile_dir | 50 args.browser_options.profile_dir = profile_dir |
| 51 args.discard_first_result = cls.tag == 'warm' |
| 50 | 52 |
| 51 def CreateUserStorySet(self, _): | 53 def CreateUserStorySet(self, _): |
| 52 """Return a user story set that only has the first user story. | 54 """Return a user story set that only has the first user story. |
| 53 | 55 |
| 54 The session restore measurement skips the navigation step and | 56 The session restore measurement skips the navigation step and |
| 55 only tests session restore by having the browser start-up. | 57 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. | 58 The first user story is used to get WPR set up and hold results. |
| 57 """ | 59 """ |
| 58 user_story_set = self.page_set() | 60 user_story_set = self.page_set() |
| 59 for user_story in user_story_set.user_stories[1:]: | 61 for user_story in user_story_set.user_stories[1:]: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 86 | 88 |
| 87 The first result is discarded. | 89 The first result is discarded. |
| 88 """ | 90 """ |
| 89 tag = 'warm' | 91 tag = 'warm' |
| 90 options = {'pageset_repeat': 20} | 92 options = {'pageset_repeat': 20} |
| 91 | 93 |
| 92 @classmethod | 94 @classmethod |
| 93 def Name(cls): | 95 def Name(cls): |
| 94 return 'session_restore.warm.typical_25' | 96 return 'session_restore.warm.typical_25' |
| 95 | 97 |
| OLD | NEW |