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

Unified Diff: tools/perf/perf_tools/page_cycler.js

Issue 13817009: [Telemetry] Make page cyclers more telemetric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make navigate conditional Created 7 years, 8 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
« no previous file with comments | « tools/perf/page_sets/page_cycler/moz2.json ('k') | tools/perf/perf_tools/page_cycler.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/perf_tools/page_cycler.js
diff --git a/tools/perf/perf_tools/page_cycler.js b/tools/perf/perf_tools/page_cycler.js
new file mode 100644
index 0000000000000000000000000000000000000000..b364146da689cd1d3b7cc9d25e2f17c750428c8b
--- /dev/null
+++ b/tools/perf/perf_tools/page_cycler.js
@@ -0,0 +1,60 @@
+// Copyright (c) 2013 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.
+
+(function() {
+// The Mozilla DHTML performance tests need to explicitly call a function to
+// trigger the next page visit, rather than directly using the onload handler.
+// To meet needs of the DHTML performance tests without forking this head.js
+// file, use a variable |__install_onload_handler| to indicate whether the
+// |__onload| handler should be added to onload event listener.
+// Install |__onload| by default if there is no pre-configuration.
+if (typeof(__install_onload_handler) == 'undefined')
+ var __install_onload_handler = true;
+
+// This is the timeout used in setTimeout inside the DHTML tests. Chrome has
+// a much more accurate timer resolution than other browsers do. This results
+// in Chrome running these tests much faster than other browsers. In order to
+// compare Chrome with other browsers on DHTML performance alone, set this
+// value to ~15.
+var __test_timeout = 0;
+
+function __set_cookie(name, value) {
+ document.cookie = name + "=" + value + "; path=/";
+}
+
+function __onbeforeunload() {
+ // Call GC twice to cleanup JS heap before starting a new test.
+ if (window.gc) {
+ window.gc();
+ window.gc();
+ }
+
+ __set_cookie("__pc_load_time", "");
+}
+
+// The function |__onload| is used by the DHTML tests.
+window.__onload = function() {
+ // window.storeCreated is used by the Indexed DB tests.
+ if ((!__install_onload_handler || window.storeCreated) &&
+ !performance.timing.loadEventEnd)
+ return;
+
+ var unused = document.body.offsetHeight; // force layout
+
+ __set_cookie("__pc_load_time", window.performance.now());
+};
+
+// The function |testComplete| is used by the Indexed DB tests.
+window.testComplete = __onload;
+
+// The function |__eval_later| now is only used by the DHTML tests.
+window.__eval_later = function(expression) {
+ setTimeout(expression, __test_timeout);
+};
+
+if (window.parent == window) { // Ignore subframes.
+ addEventListener("load", __onload);
+ addEventListener("beforeunload", __onbeforeunload);
+}
+})();
« no previous file with comments | « tools/perf/page_sets/page_cycler/moz2.json ('k') | tools/perf/perf_tools/page_cycler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698