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

Side by Side Diff: test/js-perf-test/base.js

Issue 1133843007: Adjust benchmark framework to avoid spending 50% of time on 'new Date' (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 // Performance.now is used in latency benchmarks, the fallback is Date.now. 6 // Performance.now is used in latency benchmarks, the fallback is Date.now.
7 var performance = performance || {}; 7 var performance = performance || {};
8 performance.now = (function() { 8 performance.now = (function() {
9 return performance.now || 9 return performance.now ||
10 performance.mozNow || 10 performance.mozNow ||
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 : benchmark.doDeterministic; 274 : benchmark.doDeterministic;
275 275
276 function Measure(data) { 276 function Measure(data) {
277 var elapsed = 0; 277 var elapsed = 0;
278 var start = new Date(); 278 var start = new Date();
279 279
280 // Run either for 1 second or for the number of iterations specified 280 // Run either for 1 second or for the number of iterations specified
281 // by minIterations, depending on the config flag doDeterministic. 281 // by minIterations, depending on the config flag doDeterministic.
282 for (var i = 0; (doDeterministic ? 282 for (var i = 0; (doDeterministic ?
283 i<benchmark.deterministicIterations : elapsed < 1000); i++) { 283 i<benchmark.deterministicIterations : elapsed < 1000); i++) {
284 benchmark.run(); 284 for (var j = 0; j < 100; j++) benchmark.run();
285 elapsed = new Date() - start; 285 elapsed = new Date() - start;
286 } 286 }
287 if (data != null) { 287 if (data != null) {
288 data.runs += i; 288 data.hectoruns += i;
289 data.elapsed += elapsed; 289 data.elapsed += elapsed;
290 } 290 }
291 } 291 }
292 292
293 // Sets up data in order to skip or not the warmup phase. 293 // Sets up data in order to skip or not the warmup phase.
294 if (!doWarmup && data == null) { 294 if (!doWarmup && data == null) {
295 data = { runs: 0, elapsed: 0 }; 295 data = { hectoruns: 0, elapsed: 0 };
296 } 296 }
297 297
298 if (data == null) { 298 if (data == null) {
299 Measure(null); 299 Measure(null);
300 return { runs: 0, elapsed: 0 }; 300 return { hectoruns: 0, elapsed: 0 };
301 } else { 301 } else {
302 Measure(data); 302 Measure(data);
303 // If we've run too few iterations, we continue for another second. 303 // If we've run too few iterations, we continue for another second.
304 if (data.runs < benchmark.minIterations) return data; 304 if (data.hectoruns * 100 < benchmark.minIterations) return data;
305 var usec = (data.elapsed * 1000) / data.runs; 305 var usec = (data.elapsed * 10) / data.hectoruns;
306 var rms = (benchmark.rmsResult != null) ? benchmark.rmsResult() : 0; 306 var rms = (benchmark.rmsResult != null) ? benchmark.rmsResult() : 0;
307 this.NotifyStep(new BenchmarkResult(benchmark, usec, rms)); 307 this.NotifyStep(new BenchmarkResult(benchmark, usec, rms));
308 return null; 308 return null;
309 } 309 }
310 } 310 }
311 311
312 312
313 // This function starts running a suite, but stops between each 313 // This function starts running a suite, but stops between each
314 // individual benchmark in the suite and returns a continuation 314 // individual benchmark in the suite and returns a continuation
315 // function which can be invoked to run the next benchmark. Once the 315 // function which can be invoked to run the next benchmark. Once the
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } catch (e) { 358 } catch (e) {
359 suite.NotifyError(e); 359 suite.NotifyError(e);
360 return null; 360 return null;
361 } 361 }
362 return RunNextSetup; 362 return RunNextSetup;
363 } 363 }
364 364
365 // Start out running the setup. 365 // Start out running the setup.
366 return RunNextSetup(); 366 return RunNextSetup();
367 } 367 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698