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

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

Issue 1020703002: Telemetry: Remove the class ProfileCreator. (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
OLDNEW
(Empty)
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.
4
5 from profile_creators import profile_creator
6
7 import logging
8 import page_sets
9
10 from telemetry import benchmark
11 from telemetry.page import page_test
12 from telemetry.page import test_expectations
13 from telemetry.results import results_options
14 from telemetry.user_story import user_story_runner
15
16
17 class SmallProfileCreator(profile_creator.ProfileCreator):
18 """
19 Runs a browser through a series of operations to fill in a small test profile.
20
21 This consists of performing a single navigation to each of the top 25 pages.
22 """
23 class PageTest(page_test.PageTest):
24 def __init__(self):
25 super(SmallProfileCreator.PageTest, self).__init__()
26 self._page_set = page_sets.Typical25PageSet()
27 self._ValidatePageSet(self._page_set)
28
29 # Open all links in the same tab save for the last _NUM_TABS links which
30 # are each opened in a new tab.
31 self._NUM_TABS = 5
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
42 def TabForPage(self, page, browser):
43 """Superclass override."""
44 idx = page.page_set.pages.index(page)
45 # The last _NUM_TABS pages open a new tab.
46 if idx <= (len(page.page_set.pages) - self._NUM_TABS):
47 return browser.tabs[0]
48 else:
49 return browser.tabs.New()
50
51 def ValidateAndMeasurePage(self, page, tab, results):
52 """Superclass override."""
53 tab.WaitForDocumentReadyStateToBeComplete()
54
55 def __init__(self):
56 super(SmallProfileCreator, self).__init__()
57 self._page_test = SmallProfileCreator.PageTest()
58
59 def Run(self, options):
60 expectations = test_expectations.TestExpectations()
61 results = results_options.CreateResults(
62 benchmark.BenchmarkMetadata(profile_creator.__class__.__name__),
63 options)
64 user_story_runner.Run(self._page_test, self._page_test._page_set,
65 expectations, options, results)
66
67 if results.failures:
68 logging.warning('Some pages failed to load.')
69 logging.warning('Failed pages:\n%s',
70 '\n'.join(map(str, results.pages_that_failed)))
71 raise Exception('SmallProfileCreator failed.')
OLDNEW
« no previous file with comments | « tools/perf/profile_creators/profile_generator.py ('k') | tools/perf/profile_creators/small_profile_extender.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698