Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 function benchName(bench, setup) { | |
| 6 var name = bench.name; | |
| 7 if (setup) name += "/" + setup.name; | |
| 8 } | |
| 9 | |
| 10 function slowBenchName(bench, setup) { | |
| 11 return benchName(bench, setup) + " (Slow)"; | |
| 12 } | |
| 13 | |
| 14 function slow(setupFunction) { | |
| 15 return () => { | |
| 16 setupFunction(); | |
| 17 // Trigger RegExp slow paths. | |
| 18 const regExpExec = re.exec; | |
| 19 re.exec = (str) => regExpExec.call(re, str); | |
| 20 }; | |
| 21 } | |
| 22 | |
| 23 function createHaystack() { | |
| 24 let s = "abCdefgz"; | |
|
Michael Achenbach
2016/11/24 08:25:47
Will it make a difference if you just return abCde
jgruber
2016/11/24 12:26:20
No, we could just return "abCdefgzabCdefgzabCdefgz
| |
| 25 for (let i = 0; i < 3; i++) s += s; | |
| 26 return s; | |
| 27 } | |
| 28 | |
| 29 function createBenchmarkSuite(name) { | |
| 30 return new BenchmarkSuite( | |
| 31 name, [1000], | |
| 32 benchmarks.map(([bench, setup]) => | |
| 33 new Benchmark(benchName(bench, setup), false, false, 0, bench, | |
| 34 setup))); | |
| 35 } | |
| 36 | |
| 37 function createSlowBenchmarkSuite(name) { | |
| 38 return new BenchmarkSuite( | |
| 39 "Slow" + name, [1000], | |
| 40 benchmarks.map(([bench, setup]) => | |
| 41 new Benchmark(slowBenchName(bench, setup), false, false, 0, bench, | |
| 42 slow(setup)))); | |
| 43 } | |
| OLD | NEW |