From d9a75568d6a2aec771ca17f00acf26602bbcb7e7 Mon Sep 17 00:00:00 2001 From: nednguyen Date: Thu, 23 Jul 2015 22:09:37 -0700 Subject: [PATCH] [Telemetry] Add deprecation tag for page_test.CleanUpAfterPage hook & add page_test.DidRunPage hook BUG=513487 CQ_EXTRA_TRYBOTS=tryserver.chromium.perf:mac_perf_bisect;tryserver.chromium.perf:win_perf_bisect Review URL: https://codereview.chromium.org/1242263009 Cr-Commit-Position: refs/heads/master@{#340222} --- tools/perf/measurements/blink_style.py | 4 ++-- tools/perf/measurements/draw_properties.py | 4 ++-- tools/perf/measurements/image_decoding.py | 7 +++---- tools/perf/measurements/oilpan_gc_times.py | 6 +++--- tools/perf/measurements/thread_times.py | 4 ++-- tools/perf/measurements/timeline_controller.py | 6 +++--- tools/perf/measurements/v8_gc_times.py | 6 +++--- tools/telemetry/telemetry/internal/story_runner.py | 2 ++ tools/telemetry/telemetry/page/page_test.py | 6 ++++++ tools/telemetry/telemetry/web_perf/timeline_based_page_test.py | 5 ++--- 10 files changed, 28 insertions(+), 22 deletions(-) diff --git a/tools/perf/measurements/blink_style.py b/tools/perf/measurements/blink_style.py index c573bcc7c33d..48fd449511f9 100644 --- a/tools/perf/measurements/blink_style.py +++ b/tools/perf/measurements/blink_style.py @@ -24,9 +24,9 @@ class BlinkStyle(page_test.PageTest): self._controller.SetUp(page, tab) self._controller.Start(tab) - def CleanUpAfterPage(self, page, tab): + def DidRunPage(self, platform): if self._controller: - self._controller.CleanUp(tab) + self._controller.CleanUp(platform) def ValidateAndMeasurePage(self, page, tab, results): runner = action_runner.ActionRunner(tab) diff --git a/tools/perf/measurements/draw_properties.py b/tools/perf/measurements/draw_properties.py index 3b48ee170ba7..b5c75cf75aed 100644 --- a/tools/perf/measurements/draw_properties.py +++ b/tools/perf/measurements/draw_properties.py @@ -47,7 +47,7 @@ class DrawProperties(page_test.PageTest): results.current_page, 'PT_avg_cost', 'ms', pt_avg, description='Average time spent processing property trees')) - def CleanUpAfterPage(self, page, tab): - tracing_controller = tab.browser.platform.tracing_controller + def DidRunPage(self, platform): + tracing_controller = platform.tracing_controller if tracing_controller.is_tracing_running: tracing_controller.Stop() diff --git a/tools/perf/measurements/image_decoding.py b/tools/perf/measurements/image_decoding.py index 3e21ae867f4c..2577ce13bfe5 100644 --- a/tools/perf/measurements/image_decoding.py +++ b/tools/perf/measurements/image_decoding.py @@ -98,7 +98,6 @@ class ImageDecoding(page_test.PageTest): results.current_page, 'ImageLoading_avg', 'ms', tab.EvaluateJavaScript('averageLoadingTimeMs()'))) - def CleanUpAfterPage(self, page, tab): - tracing_controller = tab.browser.platform.tracing_controller - if tracing_controller.is_tracing_running: - tracing_controller.Stop() + def DidRunPage(self, platform): + if platform.tracing_controller.is_tracing_running: + platform.tracing_controller.Stop() diff --git a/tools/perf/measurements/oilpan_gc_times.py b/tools/perf/measurements/oilpan_gc_times.py index 730f4cc13261..7fd5dcf5a734 100644 --- a/tools/perf/measurements/oilpan_gc_times.py +++ b/tools/perf/measurements/oilpan_gc_times.py @@ -155,9 +155,9 @@ class _OilpanGCTimesBase(page_test.PageTest): if thread.name == _CR_RENDERER_MAIN: _AddTracingResults(thread, results) - def CleanUpAfterPage(self, page, tab): - if tab.browser.platform.tracing_controller.is_tracing_running: - tab.browser.platform.tracing_controller.Stop() + def DidRunPage(self, platform): + if platform.tracing_controller.is_tracing_running: + platform.tracing_controller.Stop() class OilpanGCTimesForSmoothness(_OilpanGCTimesBase): diff --git a/tools/perf/measurements/thread_times.py b/tools/perf/measurements/thread_times.py index 76b94906d1ca..47c0ab06f010 100644 --- a/tools/perf/measurements/thread_times.py +++ b/tools/perf/measurements/thread_times.py @@ -43,6 +43,6 @@ class ThreadTimes(page_test.PageTest): layout_metric.AddResults(self._timeline_controller.model, renderer_thread, self._timeline_controller.smooth_records, results) - def CleanUpAfterPage(self, _, tab): + def DidRunPage(self, platform): if self._timeline_controller: - self._timeline_controller.CleanUp(tab) + self._timeline_controller.CleanUp(platform) diff --git a/tools/perf/measurements/timeline_controller.py b/tools/perf/measurements/timeline_controller.py index 5fc644b4bd7d..893f74226b14 100644 --- a/tools/perf/measurements/timeline_controller.py +++ b/tools/perf/measurements/timeline_controller.py @@ -89,9 +89,9 @@ class TimelineController(object): raise page_test.Failure('No interaction record was created.') - def CleanUp(self, tab): - if tab.browser.platform.tracing_controller.is_tracing_running: - tab.browser.platform.tracing_controller.Stop() + def CleanUp(self, platform): + if platform.tracing_controller.is_tracing_running: + platform.tracing_controller.Stop() @property def model(self): diff --git a/tools/perf/measurements/v8_gc_times.py b/tools/perf/measurements/v8_gc_times.py index 95c08a6b04de..824c88220864 100644 --- a/tools/perf/measurements/v8_gc_times.py +++ b/tools/perf/measurements/v8_gc_times.py @@ -42,9 +42,9 @@ class V8GCTimes(page_test.PageTest): renderer_process = timeline_model.GetRendererProcessFromTabId(tab.id) self._AddV8MetricsToResults(renderer_process, results) - def CleanUpAfterPage(self, page, tab): - if tab.browser.platform.tracing_controller.is_tracing_running: - tab.browser.platform.tracing_controller.Stop() + def DidRunPage(self, platform): + if platform.tracing_controller.is_tracing_running: + platform.tracing_controller.Stop() def _AddV8MetricsToResults(self, process, results): if process is None: diff --git a/tools/telemetry/telemetry/internal/story_runner.py b/tools/telemetry/telemetry/internal/story_runner.py index 9f8df9450d3b..bda8cbbade8b 100644 --- a/tools/telemetry/telemetry/internal/story_runner.py +++ b/tools/telemetry/telemetry/internal/story_runner.py @@ -104,6 +104,8 @@ def _RunStoryAndProcessErrorIfNeeded(story, results, state, test): # do not need to run test.DidRunStory at that point. if isinstance(test, story_test.StoryTest): test.DidRunStory(state.platform) + else: + test.DidRunPage(state.platform) except Exception: if not has_existing_exception: raise diff --git a/tools/telemetry/telemetry/page/page_test.py b/tools/telemetry/telemetry/page/page_test.py index 4fa795775674..af19178c7d78 100644 --- a/tools/telemetry/telemetry/page/page_test.py +++ b/tools/telemetry/telemetry/page/page_test.py @@ -5,6 +5,7 @@ import logging from telemetry.core import exceptions +from telemetry import decorators from telemetry.page import action_runner as action_runner_module @@ -144,9 +145,14 @@ class PageTest(object): """Override to do operations right after the page is navigated and after all waiting for completion has occurred.""" + @decorators.Deprecated( + 2015, 8, 10, 'This hook is deprecated. Please use DidRunPage hook instead') def CleanUpAfterPage(self, page, tab): """Called after the test run method was run, even if it failed.""" + def DidRunPage(self, platform): + """Called after the test run method was run, even if it failed.""" + def TabForPage(self, page, browser): # pylint: disable=W0613 """Override to select a different tab for the page. For instance, to create a new tab for every page, return browser.tabs.New().""" diff --git a/tools/telemetry/telemetry/web_perf/timeline_based_page_test.py b/tools/telemetry/telemetry/web_perf/timeline_based_page_test.py index e11751c43c03..ba743b7eea6d 100644 --- a/tools/telemetry/telemetry/web_perf/timeline_based_page_test.py +++ b/tools/telemetry/telemetry/web_perf/timeline_based_page_test.py @@ -24,6 +24,5 @@ class TimelineBasedPageTest(page_test.PageTest): tracing_controller = tab.browser.platform.tracing_controller self._measurement.MeasureForPageTest(tracing_controller, results) - def CleanUpAfterPage(self, page, tab): - tracing_controller = tab.browser.platform.tracing_controller - self._measurement.DidRunStoryForPageTest(tracing_controller) + def DidRunPage(self, platform): + self._measurement.DidRunStoryForPageTest(platform.tracing_controller) -- 2.11.4.GIT