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

Unified Diff: tools/page_cycler/webpagereplay/extension/page_cycler.js

Issue 9956045: Add Web Page Replay test to page cycler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows compile error. Created 8 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
Index: tools/page_cycler/webpagereplay/extension/page_cycler.js
diff --git a/tools/page_cycler/webpagereplay/extension/page_cycler.js b/tools/page_cycler/webpagereplay/extension/page_cycler.js
new file mode 100644
index 0000000000000000000000000000000000000000..76869b2902ec9bd366e03d55ac73477ac9e549db
--- /dev/null
+++ b/tools/page_cycler/webpagereplay/extension/page_cycler.js
@@ -0,0 +1,54 @@
+// 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.
+
+// Returns the sum of all values in the array.
+Array.sum = function(array) {
+ var sum = 0;
+ for (var i = array.length - 1; i >= 0; i--) {
+ sum += array[i];
+ }
+ return sum;
+};
+
+
+function WriteReport(sessionLoader) {
+ var iterations = window.iterations;
+ var reportUrl = window.benchmarkConfiguration.reportUrl;
+ var resultsCollection = sessionLoader.getResultsCollection();
+ var times = resultsCollection.getTotalTimes();
+ var pages = resultsCollection.getPages();
+
+ reportUrl += "?n=" + iterations;
+ reportUrl += "&i=" + iterations * pages.length; // "cycles"
+ reportUrl += "&td=" + Array.sum(times); // total time
+ reportUrl += "&tf=" + 0; // fudge time
+ console.log('reportUrl: ' + reportUrl);
+ chrome.cookies.set({
+ "url": reportUrl,
+ "name": "__pc_done",
+ "value": "1",
+ "path": "/",
+ });
+ chrome.cookies.set({
+ "url": reportUrl,
+ "name": "__pc_pages",
+ "value": pages.map(function(x) {
+ return x.replace(/=/g, "%3D");
+ }).join(","),
+ "path": "/",
+ });
+ chrome.cookies.set({
+ "url": reportUrl,
+ "name": "__pc_timings",
+ "value": times.join(","),
+ "path": "/",
+ });
+
+ chrome.tabs.getSelected(null, function(tab) {
+ console.log("Navigate to the report.");
+ chrome.tabs.update(tab.id, {"url": reportUrl}, null);
+ });
+}
+
+AddBenchmarkCallback(WriteReport);
« no previous file with comments | « tools/page_cycler/webpagereplay/extension/manifest.json ('k') | tools/page_cycler/webpagereplay/extension/start.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698