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

Unified Diff: tools/telemetry/telemetry/wait_interaction.py

Issue 11734036: Add robohornet as an animation test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 12 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/telemetry/telemetry/wait_interaction.py
diff --git a/tools/telemetry/telemetry/wait_interaction.py b/tools/telemetry/telemetry/wait_interaction.py
new file mode 100644
index 0000000000000000000000000000000000000000..0d0923b210de45b1dee303e7f5c350a3f66b1d5d
--- /dev/null
+++ b/tools/telemetry/telemetry/wait_interaction.py
@@ -0,0 +1,58 @@
+# 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.
+from telemetry import page_interaction
+from telemetry import util
+
+class WaitInteraction(page_interaction.PageInteraction):
+ def __init__(self, attributes=None):
+ super(WaitInteraction, self).__init__(attributes)
+
+ def PerformInteraction(self, page, tab):
+ duration = 10
+ if hasattr(self, 'duration'):
+ duration = self.duration
+
+ wait_js = """
+ window.__renderingStatsDeltas = null;
+
+ var getTimeMs = (function() {
+ if (window.performance)
+ return (performance.now ||
+ performance.mozNow ||
+ performance.msNow ||
+ performance.oNow ||
+ performance.webkitNow).bind(window.performance);
+ else
+ return function() { return new Date().getTime(); };
+ })();
+
+ var getRenderingStats = function() {
+ var renderingStats = {};
+ if (chrome &&
+ chrome.gpuBenchmarking &&
+ chrome.gpuBenchmarking.renderingStats)
+ renderingStats = chrome.gpuBenchmarking.renderingStats();
+ renderingStats.totalTimeInSeconds = getTimeMs() / 1000;
+ return renderingStats;
+ }
+
+ var initialStats = getRenderingStats();
+
+ var waitFinishedCallback = function(init) {
+ return function() {
+ var final = getRenderingStats();
+ for (var key in final)
+ final[key] -= init[key];
+ window.__renderingStatsDeltas = final;
+ };
+ }
+
+ window.setTimeout(waitFinishedCallback(initialStats), %d);
+ """ % (duration * 1000)
+
+ tab.runtime.Evaluate(wait_js)
+
+ # Poll for scroll benchmark completion.
+ util.WaitFor(lambda: tab.runtime.Evaluate(
+ 'window.__renderingStatsDeltas'), 60)
« no previous file with comments | « tools/perf/perf_tools/smoothness_benchmark.py ('k') | tools/telemetry/telemetry/wait_interaction_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698