Sort the imports of files in perf/benchmarks.
[chromium-blink-merge.git] / tools / perf / benchmarks / session_restore.py
blob462a87afb84b5ee07584967e8ef1290d0906b36b
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
3 # found in the LICENSE file.
5 from core import perf_benchmark
7 from measurements import session_restore
8 import page_sets
9 from profile_creators import profile_generator
10 from profile_creators import small_profile_extender
11 from telemetry import benchmark
14 class _SessionRestoreTypical25(perf_benchmark.PerfBenchmark):
15 """Base Benchmark class for session restore benchmarks.
17 A cold start means none of the Chromium files are in the disk cache.
18 A warm start assumes the OS has already cached much of Chromium's content.
19 For warm tests, you should repeat the page set to ensure it's cached.
21 Use Typical25PageSet to match what the SmallProfileCreator uses.
22 TODO(slamm): Make SmallProfileCreator and this use the same page_set ref.
23 """
24 page_set = page_sets.Typical25PageSet
25 tag = None # override with 'warm' or 'cold'
27 PROFILE_TYPE = 'small_profile'
29 @classmethod
30 def Name(cls):
31 return 'session_restore'
33 @classmethod
34 def ProcessCommandLineArgs(cls, parser, args):
35 super(_SessionRestoreTypical25, cls).ProcessCommandLineArgs(parser, args)
36 generator = profile_generator.ProfileGenerator(
37 small_profile_extender.SmallProfileExtender, cls.PROFILE_TYPE)
38 out_dir = generator.Run(args)
39 if out_dir:
40 args.browser_options.profile_dir = out_dir
41 else:
42 args.browser_options.dont_override_profile = True
44 @classmethod
45 def ValueCanBeAddedPredicate(cls, _, is_first_result):
46 return cls.tag == 'cold' or not is_first_result
48 def CreateStorySet(self, _):
49 """Return a story set that only has the first story.
51 The session restore measurement skips the navigation step and
52 only tests session restore by having the browser start-up.
53 The first story is used to get WPR set up and hold results.
54 """
55 story_set = self.page_set()
56 for story in story_set.stories[1:]:
57 story_set.RemoveStory(story)
58 return story_set
60 def CreatePageTest(self, options):
61 is_cold = (self.tag == 'cold')
62 return session_restore.SessionRestore(cold=is_cold)
64 def CreateStorySet(self, options):
65 return page_sets.Typical25PageSet(run_no_page_interactions=True)
67 # crbug.com/325479, crbug.com/381990
68 @benchmark.Disabled('android', 'linux', 'reference')
69 class SessionRestoreColdTypical25(_SessionRestoreTypical25):
70 """Test by clearing system cache and profile before repeats."""
71 tag = 'cold'
72 options = {'pageset_repeat': 5}
74 @classmethod
75 def Name(cls):
76 return 'session_restore.cold.typical_25'
79 # crbug.com/325479, crbug.com/381990
80 @benchmark.Disabled('android', 'linux', 'reference', 'xp')
81 class SessionRestoreWarmTypical25(_SessionRestoreTypical25):
82 """Test without clearing system cache or profile before repeats.
84 The first result is discarded.
85 """
86 tag = 'warm'
87 options = {'pageset_repeat': 20}
89 @classmethod
90 def Name(cls):
91 return 'session_restore.warm.typical_25'