diff options
author | lzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 17:34:24 +0000 |
---|---|---|
committer | lzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 17:34:24 +0000 |
commit | 4685af7696690319a792030aafb329169cb93fa2 (patch) | |
tree | ed67badaf6249cad77553de2f2302931d62052be /chrome | |
parent | 645951f0986cdaf3d8162f145b92b13a1a7ad526 (diff) | |
download | chromium_src-4685af7696690319a792030aafb329169cb93fa2.zip chromium_src-4685af7696690319a792030aafb329169cb93fa2.tar.gz chromium_src-4685af7696690319a792030aafb329169cb93fa2.tar.bz2 |
Add an option to enable/disable spdy for testing.
Also limit the url length when it is too long.
BUG=52624
TEST=none.
Review URL: http://codereview.chromium.org/3122026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56707 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
3 files changed, 50 insertions, 19 deletions
diff --git a/chrome/common/extensions/docs/examples/extensions/benchmark/background.html b/chrome/common/extensions/docs/examples/extensions/benchmark/background.html index c560e11..443ca2e 100644 --- a/chrome/common/extensions/docs/examples/extensions/benchmark/background.html +++ b/chrome/common/extensions/docs/examples/extensions/benchmark/background.html @@ -33,6 +33,7 @@ window.iterations = 10; window.clearConnections = true; window.clearCache = true; window.useNewTabs = true; +window.enableSpdy = false; window.results = {}; window.results.data = new Array(); window.testUrl = ""; @@ -93,9 +94,9 @@ function nextBenchmark() { function show_options() { chrome.tabs.getSelected(null, function(tab) { - if (window.testUrl == "") { - window.testUrl = tab.url; - } + if (window.testUrl == "") { + window.testUrl = tab.url; + } var tabs = chrome.extension.getExtensionTabs(); if (tabs && tabs.length) { tabs[0].setUrl(testUrl); @@ -144,6 +145,7 @@ function Benchmark() { current_ = {}; current_.url = url; + current_.viaSpdy = false; current_.startLoadResults = new Array(); // times to start current_.commitLoadResults = new Array(); // times to commit current_.docLoadResults = new Array(); // times to docload @@ -173,12 +175,10 @@ function Benchmark() { // Push the result. window.results.data.push(current_); - // If we're the last benchmark, close the window. if (benchmarks.length == 0) { chrome.tabs.remove(benchmarkWindow.id); benchmarkWindow = 0; - show_options(); } } @@ -223,6 +223,12 @@ function Benchmark() { chrome.benchmarking.closeConnections(); } + if (window.enableSpdy) { + chrome.benchmarking.enableSpdy(true); + } else { + chrome.benchmarking.enableSpdy(false); + } + if (benchmarkWindow) { var benchmark = nextBenchmark(); benchmark.pageStart(); @@ -242,21 +248,21 @@ function Benchmark() { } // Called when a page finishes loading. - this.pageFinished = function(csi) { - var requested = csi.requestTime; - var started = csi.startLoadTime; + this.pageFinished = function(load_times) { + var requested = load_times.requestTime; + var started = load_times.startLoadTime; var startLoadTime = - Math.round((csi.startLoadTime - requested) * 1000.0); + Math.round((load_times.startLoadTime - requested) * 1000.0); var commitLoadTime = - Math.round((csi.commitLoadTime - started) * 1000.0); + Math.round((load_times.commitLoadTime - started) * 1000.0); var docLoadTime = - Math.round((csi.finishDocumentLoadTime - started) * 1000.0); + Math.round((load_times.finishDocumentLoadTime - started) * 1000.0); var paintTime = - Math.round((csi.firstPaintTime - started) * 1000.0); + Math.round((load_times.firstPaintTime - started) * 1000.0); var totalTime = - Math.round((csi.finishLoadTime - started) * 1000.0); - var firstPaintAfterLoadTime = - Math.round((csi.firstPaintAfterLoadTime - started) * 1000.0); + Math.round((load_times.finishLoadTime - started) * 1000.0); + var firstPaintAfterLoadTime = + Math.round((load_times.firstPaintAfterLoadTime - started) * 1000.0); if (paintTime < 0) { // If the user navigates away from the test while it is running, @@ -272,7 +278,24 @@ function Benchmark() { totalTime_ += totalTime; count_++; + // Make sure the content can be fetched via spdy if it is enabled. + if (window.enableSpdy && !load_times.wasFetchedViaSpdy) { + alert("Can not fetch current url via spdy.\n" + + "Ending current test."); + runCount_ = 1; + } + + // If last fetch was via spdy, current fetch should use spdy too. Same + // for vise versa. + if (current_.iterations > 0 && + current_.viaSpdy != load_times.wasFetchedViaSpdy) { + alert("Error: viaSpdy for current fetch is different from last fetch!\n" + + "Ending current test."); + runCount_ = 1; + } + // Record the result + current_.viaSpdy = load_times.wasFetchedViaSpdy; current_.iterations++; current_.startLoadResults.push(startLoadTime); current_.commitLoadResults.push(commitLoadTime); diff --git a/chrome/common/extensions/docs/examples/extensions/benchmark/options.html b/chrome/common/extensions/docs/examples/extensions/benchmark/options.html index 057dfad7..1541d1f 100644 --- a/chrome/common/extensions/docs/examples/extensions/benchmark/options.html +++ b/chrome/common/extensions/docs/examples/extensions/benchmark/options.html @@ -292,6 +292,7 @@ function jsinit() { document.getElementById("clearconns").checked = extension.clearConnections; document.getElementById("clearcache").checked = extension.clearCache; document.getElementById("newtabs").checked = extension.useNewTabs; + document.getElementById("enablespdy").checked = extension.enableSpdy; setUrl(extension.testUrl); if (!baseline) { @@ -316,11 +317,13 @@ function config() { var clearConnections = document.getElementById("clearconns").checked; var clearCache = document.getElementById("clearcache").checked; var useNewTabs = document.getElementById("newtabs").checked; + var enableSpdy = document.getElementById("enablespdy").checked; if (iterations > 0) { extension.iterations = iterations; extension.clearConnections = clearConnections; extension.clearCache = clearCache; extension.useNewTabs = useNewTabs; + extension.enableSpdy = enableSpdy; } } @@ -374,9 +377,11 @@ function toggle(id) { <span>Iterations</span> <input id="iterations" type=text style="text-align:right"> <input type="button" value="Clear Results" onclick="clearResults();"> +<nb/> Clear Connections?<input id="clearconns" type="checkbox"> Clear Cache?<input id="clearcache" type="checkbox"> Use New Tabs Per Page?<input id="newtabs" type="checkbox"> +Enable Spdy?<input id="enablespdy" type="checkbox"> <form onsubmit="config(); run()"> URL to load <input type="text" id="testurl" size=100> <input type="submit" value="Run"><P> @@ -389,6 +394,7 @@ Use New Tabs Per Page?<input id="newtabs" type="checkbox"> <tr> <th width=200px>url</th> <th width=50>iterations</th> + <th width=50>via spdy</th> <th width=50>start load mean</th> <th width=50>commit load mean</th> <th width=50>doc load mean</th> @@ -413,6 +419,7 @@ Use New Tabs Per Page?<input id="newtabs" type="checkbox"> <tr id="t.total" jsselect="totals"> <td class="url">TOTALS <span jscontent="url"></span></td> <td class="avg" jseval="1"></td> + <td class="avg" jseval="1"></td> <td class="avg"><span jseval="val = startLoadMean.toFixed(1)" jscontent="val"></span></td> <td class="avg"><span jseval="val = commitLoadMean.toFixed(1)" jscontent="val"></span></td> <td class="avg"><span jseval="val = docLoadMean.toFixed(1)" jscontent="val"></span></td> @@ -432,8 +439,9 @@ Use New Tabs Per Page?<input id="newtabs" type="checkbox"> </tr> <tr jsselect="data"> - <td class="url" jseval="$width = getWidth($this.mean, this)"><div jsvalues=".style.width:$width" class="bggraph"><a jsvalues="href:$this.url" jscontent="url"></a></div></td> + <td class="url" jseval="$width = getWidth($this.mean, this); url.length > 40 ? $suburl = url.substring(0,27) + '...' + url.substring(url.length-10, url.length) : $suburl=url"><div jsvalues=".style.width:$width" class="bggraph"><a jsvalues="href:$this.url" jscontent="$suburl"></a></div></td> <td class="avg" jseval="val = iterations" jscontent="val"></td> + <td class="avg" jseval="val = viaSpdy" jscontent="val"></td> <td class="avg" jseval="val = startLoadMean.toFixed(1)" jscontent="val"></td> <td class="avg" jseval="val = commitLoadMean.toFixed(1)" jscontent="val"></td> <td class="avg" jseval="val = docLoadMean.toFixed(1)" jscontent="val"></td> diff --git a/chrome/common/extensions/docs/examples/extensions/benchmark/script.js b/chrome/common/extensions/docs/examples/extensions/benchmark/script.js index 0062f9c..24b52e0 100644 --- a/chrome/common/extensions/docs/examples/extensions/benchmark/script.js +++ b/chrome/common/extensions/docs/examples/extensions/benchmark/script.js @@ -14,12 +14,12 @@ function sendTimesToExtension() { return; } - var times = window.chrome.loadTimes(); + var load_times = window.chrome.loadTimes(); // If the load is not finished yet, schedule a timer to check again in a // little bit. - if (times.finishLoadTime != 0) { - benchmarkExtensionPort.postMessage({message: "load", url: benchmarkExtensionUrl, values: times}); + if (load_times.finishLoadTime != 0) { + benchmarkExtensionPort.postMessage({message: "load", url: benchmarkExtensionUrl, values: load_times}); } else { window.setTimeout(sendTimesToExtension, 100); } |