diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-17 21:32:23 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-17 21:32:23 +0000 |
commit | ca97a26cb1e8997126a7c94422725fc3507015fd (patch) | |
tree | fd9d1490f65abf8c8f9f38b61662c8df7ebf258d | |
parent | 2a8e81f9aae35d3727e95f2230ad317ff79dd463 (diff) | |
download | chromium_src-ca97a26cb1e8997126a7c94422725fc3507015fd.zip chromium_src-ca97a26cb1e8997126a7c94422725fc3507015fd.tar.gz chromium_src-ca97a26cb1e8997126a7c94422725fc3507015fd.tar.bz2 |
Several changes to the benchmark extension:
* Cleaned up the UI
- can auto-start a benchmark from a given url
* added bandwidth measurements for testing bandwidth efficiency
* added time to docload, time to first paint, in addition to overall PLT.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/155675
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21007 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 504 insertions, 431 deletions
diff --git a/chrome/test/data/extensions/samples/benchmark/options.html b/chrome/test/data/extensions/samples/benchmark/options.html index 8145632..c806551 100644 --- a/chrome/test/data/extensions/samples/benchmark/options.html +++ b/chrome/test/data/extensions/samples/benchmark/options.html @@ -1,228 +1,262 @@ -<head>
- <title>Page Benchmark Options</title>
- <script src="jst/util.js" type="text/javascript"></script>
- <script src="jst/jsevalcontext.js" type="text/javascript"></script>
- <script src="jst/jstemplate.js" type="text/javascript"></script>
- <script src="jst/jstemplate_example.js" type="text/javascript"></script>
-
-<style>
-body {
- font-size: 84%;
- font-family: Arial, Helvetica, sans-serif;
- padding: 0.75em;
- margin: 0;
- min-width: 45em;
-}
-
-h1 {
- font-size: 110%;
- font-weight: bold;
- color: #4a8ee6;
- letter-spacing: -1px;
- padding: 0;
- margin: 0;
-}
-
-div#header {
- padding: 0.75em 1em;
- padding-top: 0.6em;
- padding-left: 10;
- margin-bottom: 0.75em;
- position: relative;
- overflow: hidden;
- background: #5296de;
- -webkit-background-size: 100%;
- border: 1px solid #3a75bd;
- -webkit-border-radius: 6px;
- color: white;
- text-shadow: 0 0 2px black;
-}
-div#header h1 {
- padding-left: 37px;
- margin: 0;
- display: inline;
- color: white;
-}
-div#header p {
- font-size: 84%;
- font-style: italic;
- padding: 0;
- margin: 0;
- color: white;
- padding-left: 0.4em;
- display: inline;
-}
-
-table.list {
- font-size: 84%;
- table-layout: fixed;
-}
-
-table.list:not([class*='filtered']) tr:nth-child(odd) td:not([class*='filtered']) {
- background: #eff3ff;
-}
-
-table.list th {
- padding: 0 0.5em;
- vertical-align: top;
- font-weight: bold;
- color: #315d94;
- color: black;
- white-space: nowrap;
- text-align: center;
-}
-
-.avg {
- font-weight: bold;
- text-align: center;
-}
-
-.data {
- text-align: left;
- white-space: nowrap;
-}
-
-.bggraph {
- background-color: #faa;
- white-space: nowrap;
-}
-</style>
-
-<script>
-
-var max_sample = 0;
-
-Array.max = function(array) {
- return Math.max.apply( Math, array );
-}
-
-Array.min = function(array) {
- return Math.min.apply( Math, array );
-};
-
-// Compute the average of an array
-Array.avg = function(array) {
- var count = array.length;
- var sum = 0;
- for (var i = 0; i < count; i++) {
- sum += array[i];
- }
- return (sum / count).toFixed(1);
-}
-
-// Compute the standard deviation of an array
-Array.stddev = function(array) {
- var count = array.length;
- var mean = Array.avg(array);
- var variance = 0;
- for (var i = 0; i < count; i++) {
- var deviation = mean - array[i];
- variance = variance + deviation * deviation;
- }
- variance = variance / count;
- return Math.sqrt(variance).toFixed(2);
-}
-
-// Computes min/max/mean/stddev, etc all up front.
-function computeResults(data) {
- for (var i = 0; i < data.data.length; i++) {
- var obj = data.data[i];
- obj.mean = Array.avg(data.data[i].results);
- obj.stddev = Array.stddev(data.data[i].results);
- obj.min = Array.min(data.data[i].results);
- obj.max = Array.max(data.data[i].results);
- }
-
- // Find the biggest sample for our bar graph.
- max_sample = 0;
- for (var i = 0; i < data.data.length; i++) {
- if (data.data[i].max > max_sample) {
- max_sample = data.data[i].max;
- }
- }
-}
-
-function jsinit() {
- // Run the template to show results
- var data = window.opener.results;
- computeResults(data);
-
- var context = new JsEvalContext(data);
- context.setVariable('$width', 0);
- context.setVariable('$samples', 0);
- var template = document.getElementById("t");
- jstProcess(context, template);
-
- // Set the options
- var extension = window.opener;
- document.getElementById("iterations").value = extension.iterations;
- document.getElementById("clearconns").checked = extension.clearConnections;
- document.getElementById("clearcache").checked = extension.clearCache;
-}
-
-function getWidth(mean, max_width) {
- return Math.floor(max_width * (mean / max_sample));
-}
-
-// Apply configuration back to our extension
-function config() {
- var extension = window.opener;
- var iterations = parseInt(document.getElementById("iterations").value);
- var clearConnections = document.getElementById("clearconns").checked;
- var clearCache = document.getElementById("clearcache").checked;
- if (iterations > 0) {
- extension.iterations = iterations;
- extension.clearConnections = clearConnections;
- extension.clearCache = clearCache;
- }
-}
-
-// Clear the results
-function clearResults() {
- window.opener.results.data = new Array();
- jsinit();
-}
-</script>
-
-</head>
-
-<body onload="jsinit()">
-
-<h1><div id="header">Page Benchmark Results</div></h1>
-
-<h1>Configuration</h1>
-
-<span>Iterations</span>
-<input id="iterations" type=text style="text-align:right">
-<input type="button" value="Clear Results" onclick="clearResults();">
-Clear Connections?<input id="clearconns" type="checkbox">
-Clear Cache?<input id="clearcache" type="checkbox">
-<input type="button" value="OK" onclick="config();">
-<p>
-
-<h1>Results</h1>
-
-<table class="list" width="100%">
- <tr>
- <th width=30%>url</th>
- <th width=50>avg</th>
- <th width=50>stddev</th>
- <th width=50>min</th>
- <th width=50>max</th>
- <th samples</th>
- </tr>
-
- <tr id="t" jsselect="data">
- <td class="url" jseval="$width = getWidth($this.mean, 600)"><div jsvalues=".style.width:$width" class="bggraph"><a jsvalues="href:$this.url" jscontent="url"></a></div></td>
- <td class="avg" jscontent="mean"></td>
- <td class="avg" jscontent="stddev"></td>
- <td class="avg" jscontent="min"></td>
- <td class="avg" jscontent="max"></td>
- <td class="data"><span jsselect="results"><span jscontent="$this"></span>,</span> </td>
- </tr>
-</table>
-
-<script>
-</script>
-
-</body>
+<head> + <title>Page Benchmark Options</title> + <script src="jst/util.js" type="text/javascript"></script> + <script src="jst/jsevalcontext.js" type="text/javascript"></script> + <script src="jst/jstemplate.js" type="text/javascript"></script> + <script src="jst/jstemplate_example.js" type="text/javascript"></script> + +<style> +body { + font-size: 84%; + font-family: Arial, Helvetica, sans-serif; + padding: 0.75em; + margin: 0; + min-width: 45em; +} + +h1 { + font-size: 110%; + font-weight: bold; + color: #4a8ee6; + letter-spacing: -1px; + padding: 0; + margin: 0; +} + +div#header { + padding: 0.75em 1em; + padding-top: 0.6em; + padding-left: 10; + margin-bottom: 0.75em; + position: relative; + overflow: hidden; + background: #5296de; + -webkit-background-size: 100%; + border: 1px solid #3a75bd; + -webkit-border-radius: 6px; + color: white; + text-shadow: 0 0 2px black; +} +div#header h1 { + padding-left: 37px; + margin: 0; + display: inline; + color: white; +} +div#header p { + font-size: 84%; + font-style: italic; + padding: 0; + margin: 0; + color: white; + padding-left: 0.4em; + display: inline; +} + +table.list { + font-size: 84%; + table-layout: fixed; +} + +table.list:not([class*='filtered']) tr:nth-child(odd) td:not([class*='filtered']) { + background: #eff3ff; +} + +table.list th { + padding: 0 0.5em; + vertical-align: bottom; + font-weight: bold; + color: #315d94; + color: black; + text-align: center; +} + +.avg { + font-weight: bold; + text-align: center; +} + +.data { + text-align: left; + white-space: nowrap; +} + +.bggraph { + background-color: #faa; + white-space: nowrap; +} +</style> + +<script> + +var max_sample = 0; + +Array.max = function(array) { + return Math.max.apply( Math, array ); +} + +Array.min = function(array) { + return Math.min.apply( Math, array ); +}; + +// Compute the average of an array +Array.avg = function(array) { + var count = array.length; + var sum = 0; + for (var i = 0; i < count; i++) { + sum += array[i]; + } + return (sum / count).toFixed(1); +} + +// Compute the standard deviation of an array +Array.stddev = function(array) { + var count = array.length; + var mean = Array.avg(array); + var variance = 0; + for (var i = 0; i < count; i++) { + var deviation = mean - array[i]; + variance = variance + deviation * deviation; + } + variance = variance / count; + return Math.sqrt(variance).toFixed(2); +} + +// Computes min/max/mean/stddev, etc all up front. +function computeResults(data) { + for (var i = 0; i < data.data.length; i++) { + var obj = data.data[i]; + var resultList = obj.totalResults; + obj.mean = Array.avg(resultList); + obj.stddev = Array.stddev(resultList); + obj.min = Array.min(resultList); + obj.max = Array.max(resultList); + obj.readbps = (obj.bytesRead * 8 / obj.totalTime).toFixed(2); + obj.writebps = (obj.bytesWritten * 8 / obj.totalTime).toFixed(2); + obj.readKB = (obj.bytesRead / 1024).toFixed(0); + obj.writeKB = (obj.bytesWritten / 1024).toFixed(0); + obj.paintMean = Array.avg(obj.paintResults); + obj.docLoadMean = Array.avg(obj.docLoadResults); + } + + // Find the biggest sample for our bar graph. + max_sample = 0; + for (var i = 0; i < data.data.length; i++) { + if (data.data[i].max > max_sample) { + max_sample = data.data[i].max; + } + } +} + +function jsinit() { + // Run the template to show results + var data = window.opener.results; + computeResults(data); + + var context = new JsEvalContext(data); + context.setVariable('$width', 0); + context.setVariable('$samples', 0); + var template = document.getElementById("t"); + jstProcess(context, template); + + // Set the options + var extension = window.opener; + document.getElementById("iterations").value = extension.iterations; + document.getElementById("clearconns").checked = extension.clearConnections; + document.getElementById("clearcache").checked = extension.clearCache; + document.getElementById("testurl").value = extension.testUrl; +} + +function getWidth(mean, max_width) { + return Math.floor(max_width * (mean / max_sample)); +} + +// Apply configuration back to our extension +function config() { + var extension = window.opener; + var iterations = parseInt(document.getElementById("iterations").value); + var clearConnections = document.getElementById("clearconns").checked; + var clearCache = document.getElementById("clearcache").checked; + if (iterations > 0) { + extension.iterations = iterations; + extension.clearConnections = clearConnections; + extension.clearCache = clearCache; + } +} + +// Set the url in the benchmark url box. +function setUrl(url) { + document.getElementById("testurl").value = url; +} + +// Start the benchmark. +function run() { + var extension = window.opener; + var testUrl = document.getElementById("testurl").value; + extension.testUrl = testUrl; + extension.run(); +} + +// Clear the results +function clearResults() { + window.opener.results.data = new Array(); + jsinit(); +} +</script> + +</head> + +<body onload="jsinit()"> + +<h1><div id="header">Page Benchmark Results</div></h1> + +<h1>Configuration</h1> + +<span>Iterations</span> +<input id="iterations" type=text style="text-align:right"> +<input type="button" value="Clear Results" onclick="clearResults();"> +Clear Connections?<input id="clearconns" type="checkbox"> +Clear Cache?<input id="clearcache" type="checkbox"> +<input type="button" value="OK" onclick="config();"><P> +URL to load <input type="text" id="testurl" size=100 value="http://www.google.com/"></input> +<input type="button" value="Run" onclick="run();"><P> +<p> + +<h1>Results</h1> + +<table class="list" width="100%"> + <tr> + <th width=30%>url</th> + <th width=50>doc load mean</th> + <th width=50>paint mean</th> + <th width=50>total mean</th> + <th width=50>stddev</th> + <th width=50>min</th> + <th width=50>max</th> + <th width=50>Read KB</th> + <th width=50>Write KB</th> + <th width=50>Read KBps</th> + <th width=50>Write KBps</th> + <th samples</th> + </tr> + + <tr id="t" jsselect="data"> + <td class="url" jseval="$width = getWidth($this.mean, 600)"><div jsvalues=".style.width:$width" class="bggraph"><a jsvalues="href:$this.url" jscontent="url"></a></div></td> + <td class="avg" jscontent="docLoadMean"></td> + <td class="avg" jscontent="paintMean"></td> + <td class="avg" jscontent="mean"></td> + <td class="avg" jscontent="stddev"></td> + <td class="avg" jscontent="min"></td> + <td class="avg" jscontent="max"></td> + <td class="avg" jscontent="readKB"></td> + <td class="avg" jscontent="writeKB"></td> + <td class="avg" jscontent="readbps"></td> + <td class="avg" jscontent="writebps"></td> + <td class="data"><span jsselect="totalResults"><span jscontent="$this"></span>,</span> </td> + </tr> +</table> + +<script> +</script> + +</body> diff --git a/chrome/test/data/extensions/samples/benchmark/script.js b/chrome/test/data/extensions/samples/benchmark/script.js index cbd1bb5..75e07a4 100644 --- a/chrome/test/data/extensions/samples/benchmark/script.js +++ b/chrome/test/data/extensions/samples/benchmark/script.js @@ -1,28 +1,29 @@ -// The port for communicating back to the extension.
-var benchmarkExtensionPort = chrome.extension.connect();
-
-// The url is what this page is known to the benchmark as.
-// The benchmark uses this id to differentiate the benchmark's
-// results from random pages being browsed.
-
-// TODO(mbelshe): If the page redirects, the location changed and the
-// benchmark stalls.
-var benchmarkExtensionUrl = window.location.toString();
-
-function sendTimesToExtension() {
- var times = window.chromium.GetLoadTimes();
- if (times.finishLoadTime != 0) {
- benchmarkExtensionPort.postMessage({message: "load", url: benchmarkExtensionUrl, values: times});
- } else {
- window.setTimeout(sendTimesToExtension, 100);
- }
-}
-
-function loadComplete() {
- // Only trigger for top-level frames (e.g. the one we benchmarked)
- if (window.parent == window) {
- sendTimesToExtension();
- }
-}
-
-window.addEventListener("load", loadComplete);
+// The port for communicating back to the extension. +var benchmarkExtensionPort = chrome.extension.connect(); + +// The url is what this page is known to the benchmark as. +// The benchmark uses this id to differentiate the benchmark's +// results from random pages being browsed. + +// TODO(mbelshe): If the page redirects, the location changed and the +// benchmark stalls. +var benchmarkExtensionUrl = window.location.toString(); + +function sendTimesToExtension() { + var times = window.chrome.loadTimes(); + + if (times.finishLoadTime != 0) { + benchmarkExtensionPort.postMessage({message: "load", url: benchmarkExtensionUrl, values: times}); + } else { + window.setTimeout(sendTimesToExtension, 100); + } +} + +function loadComplete() { + // Only trigger for top-level frames (e.g. the one we benchmarked) + if (window.parent == window) { + sendTimesToExtension(); + } +} + +window.addEventListener("load", loadComplete); diff --git a/chrome/test/data/extensions/samples/benchmark/toolstrip.html b/chrome/test/data/extensions/samples/benchmark/toolstrip.html index 4ca82af..a9e1230 100644 --- a/chrome/test/data/extensions/samples/benchmark/toolstrip.html +++ b/chrome/test/data/extensions/samples/benchmark/toolstrip.html @@ -1,175 +1,213 @@ -<style>
-#options {
- position: absolute;
- background-color: #FFFFCC;
- display: none;
- font-family: "Courier New";
- font-size: 9pt;
- padding: 5px;
- border: 1px solid #CCCC88;
- z-index: 3;
-}
-</style>
-
-<script>
-var optionsForm;
-function show_options() {
- optionsForm = window.open("options.html", "optionswindow");
-}
-
-// Round a number to the 1's place.
-function formatNumber(str) {
- str += '';
- if (str == '0') {
- return 'N/A ';
- }
- var x = str.split('.');
- var x1 = x[0];
- var x2 = x.length > 1 ? '.' + x[1] : '';
- var regex = /(\d+)(\d{3})/;
- while (regex.test(x1)) {
- x1 = x1.replace(regex, '$1' + ',' + '$2');
- }
- return x1;
-}
-
-// Configuration and results are stored globally.
-window.iterations = 10;
-window.clearConnections = true;
-window.clearCache = true;
-window.results = {};
-window.results.data = new Array();
-
-function Benchmark() {
- var runCount_ = 0;
- var count_;
- var totalTime_;
- var lastWin_;
- var me_ = this;
- var current_;
-
- // Start a test run
- this.start = function(url) {
- // Check if a run is already in progress.
- if (me_.isRunning()) {
- return;
- }
-
- runCount_ = window.iterations;
- count_ = 0;
- totalTime_ = 0;
- lastWin_ = 0;
-
- current_ = {};
- current_.url = url;
- current_.results = new Array();
-
- me_.runPage();
- }
-
- // Is the benchmark currently in progress.
- this.isRunning = function() {
- return runCount_ > 0;
- }
-
- // Called when the test run completes.
- this.finish = function() {
- lastWin_.close();
- lastWin_ = 0;
-
- // push the result
- window.results.data.push(current_);
- current_ = 0;
-
- // show the latest
- show_options();
- }
-
- // Update the UI after a test run.
- this.displayResults = function() {
- var span = document.getElementById("result");
- var score = 0;
- if (count_ > 0) {
- score = totalTime_ / count_;
- }
- span.innerHTML = score.toFixed(1) + " (" + (runCount_) + ")";
- }
-
- // Run a single page in the benchmark
- this.runPage = function() {
- if (window.clearCache) {
- chromium.benchmarking.clearCache();
- }
- if (window.clearConnections) {
- chromium.benchmarking.closeConnections();
- }
-
- if (lastWin_) {
- lastWin_.location = current_.url;
- } else {
- lastWin_ = window.open(current_.url);
- }
- }
-
- // Called when a page finishes loading.
- this.pageFinished = function(csi) {
- var t = Math.round((csi.finishLoadTime - csi.startLoadTime) * 1000.0);
-
- // Record the result
- current_.results.push(t);
-
- // For our toolbar counters
- totalTime_ += t;
- count_++;
-
- if (--runCount_ > 0) {
- setTimeout(me_.runPage, 100);
- } else {
- me_.finish();
- }
-
- // Update the UI
- me_.displayResults();
- }
-}
-
-var benchmarks = new Array();
-
-chrome.self.onConnect.addListener(function(port) {
- port.onMessage.addListener(function(data) {
- if (data.message == "load") {
- var benchmark = benchmarks[data.url];
- if (benchmark != undefined && benchmark.isRunning()) {
- benchmark.pageFinished(data.values);
- }
- }
- });
-});
-
-function run() {
- show_options();
- var urls = document.getElementById("url").value.split(",");
- for (var i = 0; i < urls.length; i++) {
- var benchmark = new Benchmark();
- benchmarks[urls[i]] = benchmark;
- benchmark.start(urls[i]); // XXXMB - move to constructor
- }
-}
-</script>
-
-<style>
-#result {
- color: green;
- text-align: center;
- vertical-align: center;
-}
-</style>
-
-<div id="bench">
-<img src="stopwatch.jpg" height="25" width="25" align=top onclick="show_options()">
-<input type="text" id="url" value="http://www.google.com/"></input>
-<div class="toolstrip-button">
-<span id="run" class="open" onclick="run()">Go</span>
-</div>
-<span id="result"></span>
-</div>
+<style> +#options { + position: absolute; + background-color: #FFFFCC; + display: none; + font-family: "Courier New"; + font-size: 9pt; + padding: 5px; + border: 1px solid #CCCC88; + z-index: 3; +} +</style> + +<script> +// Round a number to the 1's place. +function formatNumber(str) { + str += ''; + if (str == '0') { + return 'N/A '; + } + var x = str.split('.'); + var x1 = x[0]; + var x2 = x.length > 1 ? '.' + x[1] : ''; + var regex = /(\d+)(\d{3})/; + while (regex.test(x1)) { + x1 = x1.replace(regex, '$1' + ',' + '$2'); + } + return x1; +} + +// Configuration and results are stored globally. +window.iterations = 10; +window.clearConnections = true; +window.clearCache = true; +window.results = {}; +window.results.data = new Array(); +window.testUrl = ""; +window.windowId = 0; + +var optionsForm = 0; +function show_options() { + // This functionality is a bit fragile, probably due to the extension API. + // If we open the window from within the getSelected() callback, then the + // window opens in a new window rather than a new tab (is that a bug?). + // If we open the window before we call getSelected(), then the selected + // tab URL will be NULL, because the page won't have loaded yet, but it will + // be the selected tab. So, we do this weird thing where we first call + // get selected, knowing that it is asynchronous. Then we open the window, + // and finally when the callback occurs for getSelected, the window will + // be created and we can use it. + chrome.tabs.getSelected(windowId, function(tab) { + window.testUrl = tab.url; + optionsForm.setUrl(window.testUrl); + }); + optionsForm = window.open("options.html", "optionswindow"); +} + +function Benchmark() { + var runCount_ = 0; + var count_; + var totalTime_; + var lastWin_; + var me_ = this; + var current_; + var initialReadBytes_; + var initialWriteBytes_; + + // Start a test run + this.start = function(url) { + // Check if a run is already in progress. + if (me_.isRunning()) { + return; + } + + console.log("Starting test for url: " + url); + + runCount_ = window.iterations; + count_ = 0; + totalTime_ = 0; + lastWin_ = 0; + + current_ = {}; + current_.url = url; + current_.docLoadResults = new Array(); // times to docload + current_.paintResults = new Array(); // times to paint + current_.totalResults = new Array(); // times to complete load + initialReadBytes = chrome.benchmarking.counter("tcp.read_bytes"); + initialWriteBytes = chrome.benchmarking.counter("tcp.write_bytes"); + + me_.runPage(); + } + + // Is the benchmark currently in progress. + this.isRunning = function() { + return runCount_ > 0; + } + + // Called when the test run completes. + this.finish = function() { + lastWin_.close(); + lastWin_ = 0; + + // Record some more stats. + current_.bytesRead = chrome.benchmarking.counter("tcp.read_bytes") - + initialReadBytes; + current_.bytesWritten = chrome.benchmarking.counter("tcp.write_bytes") - + initialWriteBytes; + current_.totalTime = totalTime_; + + // push the result + window.results.data.push(current_); + current_ = 0; + + // show the latest + show_options(); + } + + // Update the UI after a test run. + this.displayResults = function() { + var span = document.getElementById("result"); + var score = 0; + if (count_ > 0) { + score = totalTime_ / count_; + } + span.innerHTML = score.toFixed(1) + " (" + (runCount_) + ")"; + } + + // Run a single page in the benchmark + this.runPage = function() { + if (window.clearCache) { + chrome.benchmarking.clearCache(); + } + if (window.clearConnections) { + chrome.benchmarking.closeConnections(); + } + + if (lastWin_) { + lastWin_.location = current_.url; + } else { + lastWin_ = window.open(current_.url); + } + } + + // Called when a page finishes loading. + this.pageFinished = function(csi) { + var docLoadTime = + Math.round((csi.finishDocumentLoadTime - csi.startLoadTime) * 1000.0); + var paintTime = + Math.round((csi.firstPaintTime - csi.startLoadTime) * 1000.0); + var totalTime = + Math.round((csi.finishLoadTime - csi.startLoadTime) * 1000.0); + + // Record the result + current_.docLoadResults.push(docLoadTime); + current_.paintResults.push(paintTime); + current_.totalResults.push(totalTime); + + // For our toolbar counters + totalTime_ += totalTime; + count_++; + + if (--runCount_ > 0) { + setTimeout(me_.runPage, 100); + } else { + me_.finish(); + } + + // Update the UI + me_.displayResults(); + } +} + +var benchmarks = new Array(); + +chrome.self.onConnect.addListener(function(port) { + port.onMessage.addListener(function(data) { + if (data.message == "load") { + var benchmark = benchmarks[data.url]; + if (benchmark != undefined && benchmark.isRunning()) { + benchmark.pageFinished(data.values); + } + } + }); +}); + +function run() { + show_options(); + var urls = testUrl.split(","); + for (var i = 0; i < urls.length; i++) { + var benchmark = new Benchmark(); + benchmarks[urls[i]] = benchmark; + benchmark.start(urls[i]); // XXXMB - move to constructor + } +} + +// Run at startup +chrome.windows.getCurrent(function(currentWindow) { + window.windowId = currentWindow.id; +}); +</script> + +<style> +#result { + color: green; + text-align: center; + vertical-align: center; +} +</style> + +<div id="bench"> +<img src="stopwatch.jpg" height="25" width="25" align=top onclick="show_options()"> +<span id="result"></span> +</div> |