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

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

Issue 2521263003: [js-perf-test] Add RegExp microbenchmarks (Closed)
Patch Set: Move to own test suite Created 4 years 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
OLDNEW
(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";
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698