| 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);
|
|
|