| Index: chrome/test/data/v8_benchmark/base.js
|
| diff --git a/chrome/test/data/v8_benchmark/base.js b/chrome/test/data/v8_benchmark/base.js
|
| index a22920b532b42d87beebaa0ad3fef7d3e3c06be1..ffabf24ddafc91b308c328bcce3b000d3f789870 100644
|
| --- a/chrome/test/data/v8_benchmark/base.js
|
| +++ b/chrome/test/data/v8_benchmark/base.js
|
| @@ -78,7 +78,7 @@ BenchmarkSuite.suites = [];
|
| // Scores are not comparable across versions. Bump the version if
|
| // you're making changes that will affect that scores, e.g. if you add
|
| // a new benchmark or change an existing one.
|
| -BenchmarkSuite.version = '4';
|
| +BenchmarkSuite.version = '6';
|
|
|
|
|
| // To make the benchmark results predictable, we replace Math.random
|
| @@ -91,7 +91,6 @@ Math.random = (function() {
|
| seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff;
|
| seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff;
|
| seed = ((seed + 0xd3a2646c) ^ (seed << 9)) & 0xffffffff;
|
| - seed = ((seed + 0xd3a2646c) ^ (seed << 9)) & 0xffffffff;
|
| seed = ((seed + 0xfd7046c5) + (seed << 3)) & 0xffffffff;
|
| seed = ((seed ^ 0xb55a4f09) ^ (seed >>> 16)) & 0xffffffff;
|
| return (seed & 0xfffffff) / 0x10000000;
|
| @@ -199,15 +198,33 @@ BenchmarkSuite.prototype.NotifyError = function(error) {
|
|
|
| // 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;
|
| + }
|
| + }
|
| +
|
| + 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;
|
| }
|
| - var usec = (elapsed * 1000) / n;
|
| - this.NotifyStep(new BenchmarkResult(benchmark, usec));
|
| }
|
|
|
|
|
| @@ -221,6 +238,7 @@ BenchmarkSuite.prototype.RunStep = function(runner) {
|
| 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
|
| @@ -242,12 +260,13 @@ BenchmarkSuite.prototype.RunStep = function(runner) {
|
|
|
| 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() {
|
|
|