diff options
Diffstat (limited to 'deps/v8/test/js-perf-test/RegExp')
26 files changed, 599 insertions, 0 deletions
diff --git a/deps/v8/test/js-perf-test/RegExp/RegExpTests.json b/deps/v8/test/js-perf-test/RegExp/RegExpTests.json new file mode 100644 index 0000000000..ffb451cda3 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/RegExpTests.json @@ -0,0 +1,61 @@ +{ + "name": "RegExpTests", + "run_count": 5, + "run_count_android_arm": 3, + "run_count_android_arm64": 3, + "timeout": 120, + "units": "score", + "total": true, + "resources": ["base.js"], + "tests": [ + { + "name": "RegExp", + "path": ["."], + "main": "run.js", + "resources": [ + "base_ctor.js", + "base_exec.js", + "base_flags.js", + "base_match.js", + "base_replace.js", + "base_search.js", + "base_split.js", + "base_test.js", + "base.js", + "ctor.js", + "exec.js", + "flags.js", + "match.js", + "replace.js", + "search.js", + "split.js", + "test.js", + "slow_exec.js", + "slow_flags.js", + "slow_match.js", + "slow_replace.js", + "slow_search.js", + "slow_split.js", + "slow_test.js" + ], + "results_regexp": "^%s\\-RegExp\\(Score\\): (.+)$", + "tests": [ + {"name": "Ctor"}, + {"name": "Exec"}, + {"name": "Flags"}, + {"name": "Match"}, + {"name": "Replace"}, + {"name": "Search"}, + {"name": "Split"}, + {"name": "Test"}, + {"name": "SlowExec"}, + {"name": "SlowFlags"}, + {"name": "SlowMatch"}, + {"name": "SlowReplace"}, + {"name": "SlowSearch"}, + {"name": "SlowSplit"}, + {"name": "SlowTest"} + ] + } + ] +} diff --git a/deps/v8/test/js-perf-test/RegExp/base.js b/deps/v8/test/js-perf-test/RegExp/base.js new file mode 100644 index 0000000000..31f7206f07 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/base.js @@ -0,0 +1,43 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function benchName(bench, setup) { + var name = bench.name; + if (setup) name += "/" + setup.name; +} + +function slowBenchName(bench, setup) { + return benchName(bench, setup) + " (Slow)"; +} + +function slow(setupFunction) { + return () => { + setupFunction(); + // Trigger RegExp slow paths. + const regExpExec = re.exec; + re.exec = (str) => regExpExec.call(re, str); + }; +} + +function createHaystack() { + let s = "abCdefgz"; + for (let i = 0; i < 3; i++) s += s; + return s; +} + +function createBenchmarkSuite(name) { + return new BenchmarkSuite( + name, [1000], + benchmarks.map(([bench, setup]) => + new Benchmark(benchName(bench, setup), false, false, 0, bench, + setup))); +} + +function createSlowBenchmarkSuite(name) { + return new BenchmarkSuite( + "Slow" + name, [1000], + benchmarks.map(([bench, setup]) => + new Benchmark(slowBenchName(bench, setup), false, false, 0, bench, + slow(setup)))); +} diff --git a/deps/v8/test/js-perf-test/RegExp/base_ctor.js b/deps/v8/test/js-perf-test/RegExp/base_ctor.js new file mode 100644 index 0000000000..add4b6b6a3 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/base_ctor.js @@ -0,0 +1,55 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function SimpleCtor() { + new RegExp("[Cz]"); +} + +function FlagsCtor() { + new RegExp("[Cz]", "guiym"); +} + +function SimpleCtorWithoutNew() { + RegExp("[Cz]"); +} + +function FlagsCtorWithoutNew() { + RegExp("[Cz]", "guiym"); +} + +function CtorWithRegExpPattern() { + new RegExp(/[Cz]/); +} + +function CtorWithRegExpPatternAndFlags() { + new RegExp(/[Cz]/, "guiym"); +} + +class SubRegExp extends RegExp { + get source() { return "[Cz]"; } + get flags() { return "guiym"; } +} + +function CtorWithRegExpSubclassPattern() { + new RegExp(new SubRegExp(/[Cz]/)); +} + +function CtorWithUndefinedPattern() { + new RegExp(); +} + +function CtorWithFlagsAndUndefinedPattern() { + new RegExp(undefined, "guiym"); +} + +var benchmarks = [ [SimpleCtor, undefined], + [FlagsCtor, undefined], + [SimpleCtorWithoutNew, undefined], + [FlagsCtorWithoutNew, undefined], + [CtorWithRegExpPattern, undefined], + [CtorWithRegExpPatternAndFlags, undefined], + [CtorWithRegExpSubclassPattern, undefined], + [CtorWithUndefinedPattern, undefined], + [CtorWithFlagsAndUndefinedPattern, undefined], + ]; diff --git a/deps/v8/test/js-perf-test/RegExp/base_exec.js b/deps/v8/test/js-perf-test/RegExp/base_exec.js new file mode 100644 index 0000000000..ae354323a2 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/base_exec.js @@ -0,0 +1,57 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); + +var str; +var re; + +function Exec() { + re.exec(str); +} + +function Exec1Setup() { + re = /[Cz]/; + str = createHaystack(); +} + +function Exec2Setup() { + re = /[Cz]/g; + str = createHaystack(); +} + +function Exec3Setup() { + re = /([Cz])/y; + str = createHaystack(); +} + +function Exec4Setup() { + re = /[cZ]/; + str = createHaystack(); +} + +function Exec5Setup() { + re = /[cZ]/g; + str = createHaystack(); +} + +function Exec6Setup() { + re = /([cZ])/y; + str = createHaystack(); +} + +function Exec7Setup() { + re = /[Cz]/gy; + re.lastIndex = 2 ** 32; + str = createHaystack(); +} + +var benchmarks = [ [Exec, Exec1Setup], + [Exec, Exec2Setup], + [Exec, Exec3Setup], + [Exec, Exec4Setup], + [Exec, Exec5Setup], + [Exec, Exec6Setup], + [Exec, Exec7Setup], + ]; diff --git a/deps/v8/test/js-perf-test/RegExp/base_flags.js b/deps/v8/test/js-perf-test/RegExp/base_flags.js new file mode 100644 index 0000000000..837bfb3a2a --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/base_flags.js @@ -0,0 +1,21 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var re; + +function Global() { + var g = re.global; +} + +function Flags() { + var f = re.flags; +} + +function Setup() { + re = /[Cz]/giym; +} + +var benchmarks = [ [Global, Setup], + [Flags, Setup], + ]; diff --git a/deps/v8/test/js-perf-test/RegExp/base_match.js b/deps/v8/test/js-perf-test/RegExp/base_match.js new file mode 100644 index 0000000000..fd673beca7 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/base_match.js @@ -0,0 +1,32 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); + +var str; +var re; + +function SimpleMatch() { + str.match(re); +} + +function Match1Setup() { + re = /[Cz]/; + str = createHaystack(); +} + +function Match2Setup() { + re = /[Cz]/g; + str = createHaystack(); +} + +function Match3Setup() { + re = /[cZ]/; // Not found. + str = createHaystack(); +} + +var benchmarks = [ [SimpleMatch, Match1Setup], + [SimpleMatch, Match2Setup], + [SimpleMatch, Match3Setup], + ]; diff --git a/deps/v8/test/js-perf-test/RegExp/base_replace.js b/deps/v8/test/js-perf-test/RegExp/base_replace.js new file mode 100644 index 0000000000..eae66d6102 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/base_replace.js @@ -0,0 +1,54 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); + +var str; +var re; + +function StringReplace1() { + str.replace(re, ""); +} + +function StringReplace2() { + str.replace(re, "xyz"); +} + +function StringReplace3() { + str.replace(re, "x$1yz"); +} + +function FunctionReplace1() { + str.replace(re, String); +} + +function Replace1Setup() { + re = /[Cz]/; + str = createHaystack(); +} + +function Replace2Setup() { + re = /[Cz]/g; + str = createHaystack(); +} + +function Replace3Setup() { + re = /([Cz])/; + str = createHaystack(); +} + +function Replace4Setup() { + re = /([Cz])/g; + str = createHaystack(); +} + +var benchmarks = [ [ StringReplace1, Replace1Setup], + [ StringReplace1, Replace2Setup], + [ StringReplace2, Replace1Setup], + [ StringReplace2, Replace2Setup], + [ StringReplace3, Replace3Setup], + [ StringReplace3, Replace4Setup], + [ FunctionReplace1, Replace3Setup], + [ FunctionReplace1, Replace4Setup], + ]; diff --git a/deps/v8/test/js-perf-test/RegExp/base_search.js b/deps/v8/test/js-perf-test/RegExp/base_search.js new file mode 100644 index 0000000000..90d0ea94f2 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/base_search.js @@ -0,0 +1,33 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); + +var str; +var re; + +function SimpleSearch() { + str.search(re); +} + +function Search1Setup() { + re = /[Cz]/; + str = createHaystack(); +} + +function Search2Setup() { + re = /[Cz]/; + re.lastIndex = 42; // Force lastIndex restoration. + str = createHaystack(); +} + +function Search3Setup() { + re = /[cZ]/; // Not found. + str = createHaystack(); +} + +var benchmarks = [ [SimpleSearch, Search1Setup], + [SimpleSearch, Search2Setup], + [SimpleSearch, Search3Setup], + ]; diff --git a/deps/v8/test/js-perf-test/RegExp/base_split.js b/deps/v8/test/js-perf-test/RegExp/base_split.js new file mode 100644 index 0000000000..b52f623cd7 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/base_split.js @@ -0,0 +1,56 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); + +var str; +var re; + +function SimpleSplit() { + str.split(re); +} + +function Split1Setup() { + re = /[Cz]/; + str = createHaystack(); +} + +function Split2Setup() { + re = /[Cz]/u; + str = createHaystack(); +} + +function Split3Setup() { + re = /[Cz]/y; + str = createHaystack(); +} + +function Split4Setup() { + re = /[Cz]/uy; + str = createHaystack(); +} + +function Split5Setup() { + re = /[Cz]/; + str = ""; +} + +function Split6Setup() { + re = /[cZ]/; // No match. + str = createHaystack(); +} + +function Split7Setup() { + re = /[A-Za-z\u0080-\u00FF ]/; + str = "hipopótamo maçã pólen ñ poção água língüa"; +} + +var benchmarks = [ [SimpleSplit, Split1Setup], + [SimpleSplit, Split2Setup], + [SimpleSplit, Split3Setup], + [SimpleSplit, Split4Setup], + [SimpleSplit, Split5Setup], + [SimpleSplit, Split6Setup], + [SimpleSplit, Split7Setup], + ]; diff --git a/deps/v8/test/js-perf-test/RegExp/base_test.js b/deps/v8/test/js-perf-test/RegExp/base_test.js new file mode 100644 index 0000000000..d4b79451c9 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/base_test.js @@ -0,0 +1,26 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); + +var str; +var re; + +function SimpleTest() { + re.test(str); +} + +function Test1Setup() { + re = /[Cz]/; + str = createHaystack(); +} + +function Test2Setup() { + re = /[cZ]/; // Not found. + str = createHaystack(); +} + +var benchmarks = [ [SimpleTest, Test1Setup], + [SimpleTest, Test2Setup], + ]; diff --git a/deps/v8/test/js-perf-test/RegExp/ctor.js b/deps/v8/test/js-perf-test/RegExp/ctor.js new file mode 100644 index 0000000000..9876566ae7 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/ctor.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_ctor.js"); + +createBenchmarkSuite("Ctor"); diff --git a/deps/v8/test/js-perf-test/RegExp/exec.js b/deps/v8/test/js-perf-test/RegExp/exec.js new file mode 100644 index 0000000000..6b37157d36 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/exec.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_exec.js"); + +createBenchmarkSuite("Exec"); diff --git a/deps/v8/test/js-perf-test/RegExp/flags.js b/deps/v8/test/js-perf-test/RegExp/flags.js new file mode 100644 index 0000000000..b0303ddd7d --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/flags.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_flags.js"); + +createBenchmarkSuite("Flags"); diff --git a/deps/v8/test/js-perf-test/RegExp/match.js b/deps/v8/test/js-perf-test/RegExp/match.js new file mode 100644 index 0000000000..ee9e1a3df4 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/match.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_match.js"); + +createBenchmarkSuite("Match"); diff --git a/deps/v8/test/js-perf-test/RegExp/replace.js b/deps/v8/test/js-perf-test/RegExp/replace.js new file mode 100644 index 0000000000..bb7afcce41 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/replace.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_replace.js"); + +createBenchmarkSuite("Replace"); diff --git a/deps/v8/test/js-perf-test/RegExp/run.js b/deps/v8/test/js-perf-test/RegExp/run.js new file mode 100644 index 0000000000..c9ffc5729f --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/run.js @@ -0,0 +1,41 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +load('../base.js'); + +load('ctor.js'); +load('exec.js'); +load('flags.js'); +load('match.js'); +load('replace.js'); +load('search.js'); +load('split.js'); +load('test.js'); +load('slow_exec.js'); +load('slow_flags.js'); +load('slow_match.js'); +load('slow_replace.js'); +load('slow_search.js'); +load('slow_split.js'); +load('slow_test.js'); + +var success = true; + +function PrintResult(name, result) { + print(name + '-RegExp(Score): ' + result); +} + + +function PrintError(name, error) { + PrintResult(name, error); + success = false; +} + + +BenchmarkSuite.config.doWarmup = undefined; +BenchmarkSuite.config.doDeterministic = undefined; + +BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, + NotifyError: PrintError }); diff --git a/deps/v8/test/js-perf-test/RegExp/search.js b/deps/v8/test/js-perf-test/RegExp/search.js new file mode 100644 index 0000000000..3f2e0954c3 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/search.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_search.js"); + +createBenchmarkSuite("Search"); diff --git a/deps/v8/test/js-perf-test/RegExp/slow_exec.js b/deps/v8/test/js-perf-test/RegExp/slow_exec.js new file mode 100644 index 0000000000..bb1948366c --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/slow_exec.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_exec.js"); + +createSlowBenchmarkSuite("Exec"); diff --git a/deps/v8/test/js-perf-test/RegExp/slow_flags.js b/deps/v8/test/js-perf-test/RegExp/slow_flags.js new file mode 100644 index 0000000000..706937ae3c --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/slow_flags.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_flags.js"); + +createSlowBenchmarkSuite("Flags"); diff --git a/deps/v8/test/js-perf-test/RegExp/slow_match.js b/deps/v8/test/js-perf-test/RegExp/slow_match.js new file mode 100644 index 0000000000..0046b64c21 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/slow_match.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_match.js"); + +createSlowBenchmarkSuite("Match"); diff --git a/deps/v8/test/js-perf-test/RegExp/slow_replace.js b/deps/v8/test/js-perf-test/RegExp/slow_replace.js new file mode 100644 index 0000000000..c0726175f1 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/slow_replace.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_replace.js"); + +createSlowBenchmarkSuite("Replace"); diff --git a/deps/v8/test/js-perf-test/RegExp/slow_search.js b/deps/v8/test/js-perf-test/RegExp/slow_search.js new file mode 100644 index 0000000000..cb95acc768 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/slow_search.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_search.js"); + +createSlowBenchmarkSuite("Search"); diff --git a/deps/v8/test/js-perf-test/RegExp/slow_split.js b/deps/v8/test/js-perf-test/RegExp/slow_split.js new file mode 100644 index 0000000000..4ab0609945 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/slow_split.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_split.js"); + +createSlowBenchmarkSuite("Split"); diff --git a/deps/v8/test/js-perf-test/RegExp/slow_test.js b/deps/v8/test/js-perf-test/RegExp/slow_test.js new file mode 100644 index 0000000000..0c69addacd --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/slow_test.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_test.js"); + +createSlowBenchmarkSuite("Test"); diff --git a/deps/v8/test/js-perf-test/RegExp/split.js b/deps/v8/test/js-perf-test/RegExp/split.js new file mode 100644 index 0000000000..4afea522c9 --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/split.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_split.js"); + +createBenchmarkSuite("Split"); diff --git a/deps/v8/test/js-perf-test/RegExp/test.js b/deps/v8/test/js-perf-test/RegExp/test.js new file mode 100644 index 0000000000..f9b8ee545d --- /dev/null +++ b/deps/v8/test/js-perf-test/RegExp/test.js @@ -0,0 +1,8 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load("base.js"); +load("base_test.js"); + +createBenchmarkSuite("Test"); |