Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2447)

Unified Diff: benchmarks/base.js

Issue 2836031: Update the V8 benchmark suite with the following fixes:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « benchmarks/README.txt ('k') | benchmarks/crypto.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: benchmarks/base.js
===================================================================
--- benchmarks/base.js (revision 4958)
+++ benchmarks/base.js (working copy)
@@ -198,15 +198,33 @@
// Runs a single benchmark for at least a second and computes the
// average time it takes to run a single iteration.
-BenchmarkSuite.prototype.RunSingleBenchmark = function(benchmark) {
- var elapsed = 0;
- var start = new Date();
- for (var n = 0; elapsed < 1000; n++) {
- benchmark.run();
- elapsed = new Date() - start;
+BenchmarkSuite.prototype.RunSingleBenchmark = function(benchmark, data) {
+ function Measure(data) {
+ var elapsed = 0;
+ var start = new Date();
+ for (var n = 0; elapsed < 1000; n++) {
+ benchmark.run();
+ elapsed = new Date() - start;
+ }
+ if (data != null) {
+ data.runs += n;
+ data.elapsed += elapsed;
+ }
}
- var usec = (elapsed * 1000) / n;
- this.NotifyStep(new BenchmarkResult(benchmark, usec));
+
+ if (data == null) {
+ // Measure the benchmark once for warm up and throw the result
+ // away. Return a fresh data object.
+ Measure(null);
+ return { runs: 0, elapsed: 0 };
+ } else {
+ Measure(data);
+ // If we've run too few iterations, we continue for another second.
+ if (data.runs < 32) return data;
+ var usec = (data.elapsed * 1000) / data.runs;
+ this.NotifyStep(new BenchmarkResult(benchmark, usec));
+ return null;
+ }
}
@@ -220,6 +238,7 @@
var length = this.benchmarks.length;
var index = 0;
var suite = this;
+ var data;
// Run the setup, the actual benchmark, and the tear down in three
// separate steps to allow the framework to yield between any of the
@@ -241,12 +260,13 @@
function RunNextBenchmark() {
try {
- suite.RunSingleBenchmark(suite.benchmarks[index]);
+ data = suite.RunSingleBenchmark(suite.benchmarks[index], data);
} catch (e) {
suite.NotifyError(e);
return null;
}
- return RunNextTearDown;
+ // If data is null, we're done with this benchmark.
+ return (data == null) ? RunNextTearDown : RunNextBenchmark();
}
function RunNextTearDown() {
« no previous file with comments | « benchmarks/README.txt ('k') | benchmarks/crypto.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698