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

Unified Diff: tools/perf/perf_tools/scrolling_benchmark.py

Issue 11316017: Refactoring scrolling_benchmark code into scrolling_interaction.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Trying out marja's suggestion Created 8 years, 1 month 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/perf_tools/scrolling_benchmark.py
diff --git a/tools/perf/perf_tools/scrolling_benchmark.py b/tools/perf/perf_tools/scrolling_benchmark.py
index cf1c944fb5430de034eb22393d0ac0025cd08cbf..72c4901db9c454e1530dcc6ac85b9159ffc28a44 100644
--- a/tools/perf/perf_tools/scrolling_benchmark.py
+++ b/tools/perf/perf_tools/scrolling_benchmark.py
@@ -1,14 +1,7 @@
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import os
-
from telemetry import multi_page_benchmark
-from telemetry import util
-
-class DidNotScrollException(multi_page_benchmark.MeasurementFailure):
- def __init__(self):
- super(DidNotScrollException, self).__init__('Page did not scroll')
def GetOrZero(stat, rendering_stats_deltas):
if stat in rendering_stats_deltas:
@@ -66,7 +59,7 @@ def CalcScrollResults(rendering_stats_deltas, results):
class ScrollingBenchmark(multi_page_benchmark.MultiPageBenchmark):
def __init__(self):
- super(ScrollingBenchmark, self).__init__()
+ super(ScrollingBenchmark, self).__init__('scrolling')
def AddCommandLineOptions(self, parser):
parser.add_option('--no-gpu-benchmarking-extension', action='store_true',
@@ -76,52 +69,15 @@ class ScrollingBenchmark(multi_page_benchmark.MultiPageBenchmark):
action='store_true',
help='Reports all data collected, not just FPS')
- @staticmethod
- def ScrollPageFully(page, tab):
- scroll_js_path = os.path.join(os.path.dirname(__file__), 'scroll.js')
- scroll_js = open(scroll_js_path, 'r').read()
-
- # Run scroll test.
- tab.runtime.Execute(scroll_js)
-
- with tab.browser.platform.GetSurfaceCollector(''):
-
- start_scroll_js = """
- window.__renderingStatsDeltas = null;
- new __ScrollTest(function(rendering_stats_deltas) {
- window.__renderingStatsDeltas = rendering_stats_deltas;
- }).start(element);
- """
- # scrollable_element_function is a function that passes the scrollable
- # element on the page to a callback. For example:
- # function (callback) {
- # callback(document.getElementById('foo'));
- # }
- if hasattr(page, 'scrollable_element_function'):
- tab.runtime.Execute('(%s)(function(element) { %s });' %
- (page.scrollable_element_function, start_scroll_js))
- else:
- tab.runtime.Execute(
- '(function() { var element = document.body; %s})();' %
- start_scroll_js)
-
- # Poll for scroll benchmark completion.
- util.WaitFor(lambda: tab.runtime.Evaluate(
- 'window.__renderingStatsDeltas'), 60)
-
- rendering_stats_deltas = tab.runtime.Evaluate(
- 'window.__renderingStatsDeltas')
-
- if not (rendering_stats_deltas['numFramesSentToScreen'] > 0):
- raise DidNotScrollException()
- return rendering_stats_deltas
-
def CustomizeBrowserOptions(self, options):
if not options.no_gpu_benchmarking_extension:
options.extra_browser_args.append('--enable-gpu-benchmarking')
+ def CanRunForPage(self, page):
+ return hasattr(page, 'scrolling')
+
def MeasurePage(self, page, tab, results):
- rendering_stats_deltas = self.ScrollPageFully(page, tab)
+ rendering_stats_deltas = page.scroll_results
CalcScrollResults(rendering_stats_deltas, results)
if self.options.report_all_results:
for k, v in rendering_stats_deltas.iteritems():

Powered by Google App Engine
This is Rietveld 408576698