1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Returns the sum of all values in the array.
6 Array.sum = function(array) {
8 for (var i = array.length - 1; i >= 0; i--) {
15 function WriteReport(sessionLoader) {
16 var iterations = window.iterations;
17 var reportUrl = window.benchmarkConfiguration.reportUrl;
18 var resultsCollection = sessionLoader.getResultsCollection();
19 var times = resultsCollection.getTotalTimes();
20 var pages = resultsCollection.getPages();
22 reportUrl += "?n=" + iterations;
23 reportUrl += "&i=" + iterations * pages.length; // "cycles"
24 reportUrl += "&td=" + Array.sum(times); // total time
25 reportUrl += "&tf=" + 0; // fudge time
26 console.log('reportUrl: ' + reportUrl);
36 "value": pages.map(function(x) {
37 return x.replace(/=/g, "%3D");
43 "name": "__pc_timings",
44 "value": times.join(","),
48 chrome.tabs.getSelected(null, function(tab) {
49 console.log("Navigate to the report.");
50 chrome.tabs.update(tab.id, {"url": reportUrl}, null);
54 AddBenchmarkCallback(WriteReport);