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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tools/perf/profile_creators/small_profile_creator.py
diff --git a/tools/perf/profile_creators/small_profile_creator.py b/tools/perf/profile_creators/small_profile_creator.py
index d8bb4532be2c418d257c365283e6d786d340b4b0..46109a7a4f341a536c73cb5e47498f07a2c37085 100644
--- a/tools/perf/profile_creators/small_profile_creator.py
+++ b/tools/perf/profile_creators/small_profile_creator.py
@@ -4,29 +4,58 @@
from telemetry.page import profile_creator
+import logging
import page_sets
+from telemetry import benchmark
+from telemetry.page import page_test
+from telemetry.page import test_expectations
+from telemetry.results import results_options
+from telemetry.user_story import user_story_runner
+
class SmallProfileCreator(profile_creator.ProfileCreator):
"""
Runs a browser through a series of operations to fill in a small test profile.
+
+ This consists of performing a single navigation to each of the top 25 pages.
"""
+ class PageTest(page_test.PageTest):
+ def __init__(self):
+ super(SmallProfileCreator.PageTest, self).__init__()
+ self._page_set = page_sets.Typical25PageSet()
+
+ # Open all links in the same tab save for the last _NUM_TABS links which
+ # are each opened in a new tab.
+ self._NUM_TABS = 5
+
+ def TabForPage(self, page, browser):
+ """Superclass override."""
+ idx = page.page_set.pages.index(page)
+ # The last _NUM_TABS pages open a new tab.
+ if idx <= (len(page.page_set.pages) - self._NUM_TABS):
+ return browser.tabs[0]
+ else:
+ return browser.tabs.New()
+
+ def ValidateAndMeasurePage(self, page, tab, results):
+ """Superclass override."""
+ tab.WaitForDocumentReadyStateToBeComplete()
def __init__(self):
super(SmallProfileCreator, self).__init__()
- self._page_set = page_sets.Typical25PageSet()
-
- # Open all links in the same tab save for the last _NUM_TABS links which
- # are each opened in a new tab.
- self._NUM_TABS = 5
-
- def TabForPage(self, page, browser):
- idx = page.page_set.pages.index(page)
- # The last _NUM_TABS pages open a new tab.
- if idx <= (len(page.page_set.pages) - self._NUM_TABS):
- return browser.tabs[0]
- else:
- return browser.tabs.New()
-
- def ValidateAndMeasurePage(self, _, tab, results):
- tab.WaitForDocumentReadyStateToBeComplete()
+ self._page_test = SmallProfileCreator.PageTest()
+
+ def Run(self, options):
+ expectations = test_expectations.TestExpectations()
+ results = results_options.CreateResults(
+ benchmark.BenchmarkMetadata(profile_creator.__class__.__name__),
+ options)
+ user_story_runner.Run(self._page_test, self._page_test._page_set,
+ expectations, options, results)
+
+ if results.failures:
+ logging.warning('Some pages failed to load.')
+ logging.warning('Failed pages:\n%s',
+ '\n'.join(map(str, results.pages_that_failed)))
+ raise Exception('SmallProfileCreator failed.')
« 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