Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: tools/perf/profile_creators/small_profile_creator.py

Issue 980073005: Move PageTest.ValidatePageSet special-case into profile creator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/perf/measurements/session_restore.py ('k') | tools/telemetry/telemetry/page/page_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 from telemetry.page import profile_creator 5 from telemetry.page import profile_creator
6 6
7 import logging 7 import logging
8 import page_sets 8 import page_sets
9 9
10 from telemetry import benchmark 10 from telemetry import benchmark
11 from telemetry.page import page_test 11 from telemetry.page import page_test
12 from telemetry.page import test_expectations 12 from telemetry.page import test_expectations
13 from telemetry.results import results_options 13 from telemetry.results import results_options
14 from telemetry.user_story import user_story_runner 14 from telemetry.user_story import user_story_runner
15 15
16 16
17 class SmallProfileCreator(profile_creator.ProfileCreator): 17 class SmallProfileCreator(profile_creator.ProfileCreator):
18 """ 18 """
19 Runs a browser through a series of operations to fill in a small test profile. 19 Runs a browser through a series of operations to fill in a small test profile.
20 20
21 This consists of performing a single navigation to each of the top 25 pages. 21 This consists of performing a single navigation to each of the top 25 pages.
22 """ 22 """
23 class PageTest(page_test.PageTest): 23 class PageTest(page_test.PageTest):
24 def __init__(self): 24 def __init__(self):
25 super(SmallProfileCreator.PageTest, self).__init__() 25 super(SmallProfileCreator.PageTest, self).__init__()
26 self._page_set = page_sets.Typical25PageSet() 26 self._page_set = page_sets.Typical25PageSet()
27 self._ValidatePageSet(self._page_set)
27 28
28 # Open all links in the same tab save for the last _NUM_TABS links which 29 # Open all links in the same tab save for the last _NUM_TABS links which
29 # are each opened in a new tab. 30 # are each opened in a new tab.
30 self._NUM_TABS = 5 31 self._NUM_TABS = 5
31 32
33 @staticmethod
34 def _ValidatePageSet(page_set):
35 """Raise an exception if |page_set| uses more than one WPR archive."""
36 wpr_paths = set(page_set.WprFilePathForUserStory(p)
37 for p in page_set if not p.is_local)
38 if len(wpr_paths) > 1:
39 raise Exception("Invalid page set: has multiple WPR archives: %s" %
40 ','.join(sorted(wpr_paths)))
41
32 def TabForPage(self, page, browser): 42 def TabForPage(self, page, browser):
33 """Superclass override.""" 43 """Superclass override."""
34 idx = page.page_set.pages.index(page) 44 idx = page.page_set.pages.index(page)
35 # The last _NUM_TABS pages open a new tab. 45 # The last _NUM_TABS pages open a new tab.
36 if idx <= (len(page.page_set.pages) - self._NUM_TABS): 46 if idx <= (len(page.page_set.pages) - self._NUM_TABS):
37 return browser.tabs[0] 47 return browser.tabs[0]
38 else: 48 else:
39 return browser.tabs.New() 49 return browser.tabs.New()
40 50
41 def ValidateAndMeasurePage(self, page, tab, results): 51 def ValidateAndMeasurePage(self, page, tab, results):
(...skipping 10 matching lines...) Expand all
52 benchmark.BenchmarkMetadata(profile_creator.__class__.__name__), 62 benchmark.BenchmarkMetadata(profile_creator.__class__.__name__),
53 options) 63 options)
54 user_story_runner.Run(self._page_test, self._page_test._page_set, 64 user_story_runner.Run(self._page_test, self._page_test._page_set,
55 expectations, options, results) 65 expectations, options, results)
56 66
57 if results.failures: 67 if results.failures:
58 logging.warning('Some pages failed to load.') 68 logging.warning('Some pages failed to load.')
59 logging.warning('Failed pages:\n%s', 69 logging.warning('Failed pages:\n%s',
60 '\n'.join(map(str, results.pages_that_failed))) 70 '\n'.join(map(str, results.pages_that_failed)))
61 raise Exception('SmallProfileCreator failed.') 71 raise Exception('SmallProfileCreator failed.')
OLDNEW
« no previous file with comments | « tools/perf/measurements/session_restore.py ('k') | tools/telemetry/telemetry/page/page_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698