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

Side by Side Diff: test/js-perf-test/RegExp/base_replace.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 load("base.js");
6
7 var str;
8 var re;
9
10 function StringReplace1() {
11 str.replace(re, "");
12 }
13
14 function StringReplace2() {
15 str.replace(re, "xyz");
16 }
17
18 function StringReplace3() {
19 str.replace(re, "x$1yz");
20 }
21
22 function FunctionReplace1() {
23 str.replace(re, String);
24 }
25
26 function Replace1Setup() {
27 re = /[Cz]/;
28 str = createHaystack();
29 }
30
31 function Replace2Setup() {
32 re = /[Cz]/g;
33 str = createHaystack();
34 }
35
36 function Replace3Setup() {
37 re = /([Cz])/;
38 str = createHaystack();
39 }
40
41 function Replace4Setup() {
42 re = /([Cz])/g;
43 str = createHaystack();
44 }
45
46 var benchmarks = [ [ StringReplace1, Replace1Setup],
47 [ StringReplace1, Replace2Setup],
48 [ StringReplace2, Replace1Setup],
49 [ StringReplace2, Replace2Setup],
50 [ StringReplace3, Replace3Setup],
51 [ StringReplace3, Replace4Setup],
52 [ FunctionReplace1, Replace3Setup],
53 [ FunctionReplace1, Replace4Setup],
54 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698