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

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

Issue 825703003: Change profile_creator to not subclass page_test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@telemetry_profile_generation
Patch Set: Rebase against top of tree. Created 5 years, 11 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
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 page_sets 8 import page_sets
8 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
9 16
10 class SmallProfileCreator(profile_creator.ProfileCreator): 17 class SmallProfileCreator(profile_creator.ProfileCreator):
11 """ 18 """
12 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
21 This consists of performing a single navigation to each of the top 25 pages.
13 """ 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
28 # Open all links in the same tab save for the last _NUM_TABS links which
29 # are each opened in a new tab.
30 self._NUM_TABS = 5
31
32 def TabForPage(self, page, browser):
33 """Superclass override."""
34 idx = page.page_set.pages.index(page)
35 # The last _NUM_TABS pages open a new tab.
36 if idx <= (len(page.page_set.pages) - self._NUM_TABS):
37 return browser.tabs[0]
38 else:
39 return browser.tabs.New()
40
41 def ValidateAndMeasurePage(self, page, tab, results):
42 """Superclass override."""
43 tab.WaitForDocumentReadyStateToBeComplete()
14 44
15 def __init__(self): 45 def __init__(self):
16 super(SmallProfileCreator, self).__init__() 46 super(SmallProfileCreator, self).__init__()
17 self._page_set = page_sets.Typical25PageSet() 47 self._page_test = SmallProfileCreator.PageTest()
18 48
19 # Open all links in the same tab save for the last _NUM_TABS links which 49 def Run(self, options):
20 # are each opened in a new tab. 50 expectations = test_expectations.TestExpectations()
21 self._NUM_TABS = 5 51 results = results_options.CreateResults(
52 benchmark.BenchmarkMetadata(profile_creator.__class__.__name__),
53 options)
54 user_story_runner.Run(self._page_test, self._page_test._page_set,
55 expectations, options, results)
22 56
23 def TabForPage(self, page, browser): 57 if results.failures:
24 idx = page.page_set.pages.index(page) 58 logging.warning('Some pages failed to load.')
25 # The last _NUM_TABS pages open a new tab. 59 logging.warning('Failed pages:\n%s',
26 if idx <= (len(page.page_set.pages) - self._NUM_TABS): 60 '\n'.join(map(str, results.pages_that_failed)))
27 return browser.tabs[0] 61 raise Exception('SmallProfileCreator failed.')
28 else:
29 return browser.tabs.New()
30
31 def ValidateAndMeasurePage(self, _, tab, results):
32 tab.WaitForDocumentReadyStateToBeComplete()
OLDNEW
« no previous file with comments | « tools/perf/profile_creators/extensions_profile_creator.py ('k') | tools/telemetry/telemetry/page/profile_creator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698