diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-18 00:37:41 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-18 00:37:41 +0000 |
commit | 9c3a263d00aeb2ad7f858f292f18408407d62afa (patch) | |
tree | 6d701f496fe7a4db65c059422eb88e0568645f42 /chrome | |
parent | 0808130f33f7e949b29387298006afee154ff371 (diff) | |
download | chromium_src-9c3a263d00aeb2ad7f858f292f18408407d62afa.zip chromium_src-9c3a263d00aeb2ad7f858f292f18408407d62afa.tar.gz chromium_src-9c3a263d00aeb2ad7f858f292f18408407d62afa.tar.bz2 |
Fix a few benchmark bugs and add some more enhancements:
- benchmarkIndex was not reset between runs, which caused it to
sometimes run slightly out-of-order.
- rework the way we record initial counters to be on the object rather
than accidentally global.
- add iterations to the output
- add # requests to the output
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/501058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34906 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/common/extensions/docs/examples/extensions/benchmark/background.html | 42 | ||||
-rw-r--r-- | chrome/common/extensions/docs/examples/extensions/benchmark/options.html | 18 |
2 files changed, 43 insertions, 17 deletions
diff --git a/chrome/common/extensions/docs/examples/extensions/benchmark/background.html b/chrome/common/extensions/docs/examples/extensions/benchmark/background.html index 209ac5a..9c8ac52 100644 --- a/chrome/common/extensions/docs/examples/extensions/benchmark/background.html +++ b/chrome/common/extensions/docs/examples/extensions/benchmark/background.html @@ -37,6 +37,11 @@ window.results.data = new Array(); window.testUrl = ""; window.windowId = 0; +// Constant StatCounter Names +var kTCPReadBytes = "tcp.read_bytes"; +var kTCPWriteBytes = "tcp.write_bytes"; +var kRequestCount = "HttpNetworkTransaction.Count"; + // The list of currently running benchmarks var benchmarks = new Array(); var benchmarkIndex = 0; @@ -44,6 +49,7 @@ var benchmarkWindow = 0; function addBenchmark(benchmark) { benchmarks.push(benchmark); + benchmarkIndex = 0; // Reset the counter when adding benchmarks. } // Array Remove - By John Resig (MIT Licensed) @@ -113,6 +119,7 @@ function Benchmark() { var totalTime_; var me_ = this; var current_; + var initialRequestCount_; var initialReadBytes_; var initialWriteBytes_; @@ -140,6 +147,8 @@ function Benchmark() { current_.bytesRead = 0; current_.bytesWritten = 0; current_.totalTime = 0; + current_.iterations = 0; + current_.requests = 0; } // Is the benchmark currently in progress. @@ -187,6 +196,13 @@ function Benchmark() { } } + // Called before starting a page load. + this.pageStart = function() { + initialReadBytes_ = chrome.benchmarking.counter(kTCPReadBytes); + initialWriteBytes_ = chrome.benchmarking.counter(kTCPWriteBytes); + initialRequestCount_ = chrome.benchmarking.counter(kRequestCount); + } + // Run a single page in the benchmark this.runPage = function() { if (window.clearCache) { @@ -197,14 +213,12 @@ function Benchmark() { chrome.benchmarking.closeConnections(); } - initialReadBytes = chrome.benchmarking.counter("tcp.read_bytes"); - initialWriteBytes = chrome.benchmarking.counter("tcp.write_bytes"); - - if (benchmarkWindow) { var benchmark = nextBenchmark(); + benchmark.pageStart(); chrome.tabs.update(benchmarkWindow.id, {"url": benchmark.url() }); } else { + this.pageStart(); chrome.tabs.create({"url": current_.url }, function(tab) { benchmarkWindow = tab; }); } @@ -221,9 +235,12 @@ function Benchmark() { if (paintTime < 0) { // If the user navigates away from the test while it is running, - // paint may not occur. - alert("No paint detected. Did you navigate while the test was running?"); - paintTime = totalTime; // approximate. + // paint may not occur. Also, some lightweight pages, such as the + // google home page, never trigger a paint measurement via the chrome + // page load timer. + // In this case, the time-to-first paint is effectively the same as the + // time to onLoad(). + paintTime = totalTime; } // For our toolbar counters @@ -231,13 +248,16 @@ function Benchmark() { count_++; // Record the result + current_.iterations++; current_.docLoadResults.push(docLoadTime); current_.paintResults.push(paintTime); current_.totalResults.push(totalTime); - current_.bytesRead += chrome.benchmarking.counter("tcp.read_bytes") - - initialReadBytes; - current_.bytesWritten += chrome.benchmarking.counter("tcp.write_bytes") - - initialWriteBytes; + current_.bytesRead += chrome.benchmarking.counter(kTCPReadBytes) - + initialReadBytes_; + current_.bytesWritten += chrome.benchmarking.counter(kTCPWriteBytes) - + initialWriteBytes_; + current_.requests += chrome.benchmarking.counter(kRequestCount) - + initialRequestCount_; current_.totalTime += totalTime; if (--runCount_ == 0) { diff --git a/chrome/common/extensions/docs/examples/extensions/benchmark/options.html b/chrome/common/extensions/docs/examples/extensions/benchmark/options.html index 4df1db3..34f203c 100644 --- a/chrome/common/extensions/docs/examples/extensions/benchmark/options.html +++ b/chrome/common/extensions/docs/examples/extensions/benchmark/options.html @@ -131,7 +131,7 @@ Array.stddev = function(array) { variance = variance + deviation * deviation; } variance = variance / count; - return Math.sqrt(variance).toFixed(2); + return Math.sqrt(variance); } // Object to summarize everything @@ -171,11 +171,11 @@ function computeResults(data) { totals.docLoadMean /= count; } - // Find the biggest sample for our bar graph. + // Find the biggest average 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; + max_sample = data.data[i].mean; } } } @@ -200,7 +200,8 @@ function jsinit() { setUrl(extension.testUrl); } -function getWidth(mean, max_width) { +function getWidth(mean, obj) { + var max_width = obj.offsetWidth; return Math.floor(max_width * (mean / max_sample)); } @@ -265,12 +266,14 @@ Clear Cache?<input id="clearcache" type="checkbox"> <table id="t" class="list" width="100%"> <tr> <th width=30%>url</th> + <th width=50>iterations</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># Requests</th> <th width=50>Read KB</th> <th width=50>Write KB</th> <th width=50>Read KBps</th> @@ -280,6 +283,7 @@ Clear Cache?<input id="clearcache" 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"><span jseval="val = docLoadMean.toFixed(1)" jscontent="val"></span></td> <td class="avg"><span jseval="val = paintMean.toFixed(1)" jscontent="val"></span></td> <td class="avg"><span jseval="val = mean.toFixed(1)" jscontent="val"></span></td> @@ -290,17 +294,20 @@ Clear Cache?<input id="clearcache" type="checkbox"> <td class="avg" jseval="1"></td> <td class="avg" jseval="1"></td> <td class="avg" jseval="1"></td> + <td class="avg" jseval="1"></td> <td class="data"></td> </tr> <tr 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="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="avg" jseval="val = iterations" jscontent="val"></td> <td class="avg" jseval="val = docLoadMean.toFixed(1)" jscontent="val"></td> <td class="avg" jseval="val = paintMean.toFixed(1)" jscontent="val"></td> <td class="avg" jseval="val = mean.toFixed(1)" jscontent="val"></td> <td class="avg" jseval="val = stddev.toFixed(1)" jscontent="val"></td> <td class="avg" jseval="val = min.toFixed(1)" jscontent="val"></td> <td class="avg" jseval="val = max.toFixed(1)" jscontent="val"></td> + <td class="avg" jseval="val = requests" jscontent="val"></td> <td class="avg" jseval="val = readKB.toFixed(1)" jscontent="val"></td> <td class="avg" jseval="val = writeKB.toFixed(1)" jscontent="val"></td> <td class="avg" jseval="val = readbps.toFixed(1)" jscontent="val"></td> @@ -310,7 +317,6 @@ Clear Cache?<input id="clearcache" type="checkbox"> <tr jsdisplay="data.length == 0"> <td colspan=11>No tests have been run yet.</td> </tr> - </div> </table> <script> |