Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: compare charcode on valid_regex_flags
baseline 256 small regexp literal with all flags: 4342 ops/sec 卤1.57% (0.23ms) baseline 512 small regexp literal with all flags: 2213 ops/sec 卤1.51% (0.452ms) baseline 1024 small regexp literal with all flags: 1144 ops/sec 卤0.22% (0.874ms) baseline 2048 small regexp literal with all flags: 541 ops/sec 卤1.12% (1.849ms) current 256 small regexp literal with all flags: 4643 ops/sec 卤1.3% (0.215ms) current 512 small regexp literal with all flags: 2355 ops/sec 卤1.14% (0.425ms) current 1024 small regexp literal with all flags: 1176 ops/sec 卤0.87% (0.85ms) current 2048 small regexp literal with all flags: 553 ops/sec 卤1.31% (1.807ms)
- Loading branch information
Showing
2 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
packages/babel-parser/benchmark/many-small-all-flags-regexp/bench.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Benchmark from "benchmark"; | ||
import baseline from "../../lib/index-v2.js"; | ||
import current from "../../lib/index.js"; | ||
import { report } from "../util.mjs"; | ||
|
||
const suite = new Benchmark.Suite(); | ||
function createInput(length) { | ||
return "/x/dgimsuy;".repeat(length); | ||
} | ||
function benchCases(name, implementation, options) { | ||
for (const length of [256, 512, 1024, 2048]) { | ||
const input = createInput(length); | ||
suite.add(`${name} ${length} small regexp literal with all flags`, () => { | ||
implementation.parse(input, options); | ||
}); | ||
} | ||
} | ||
|
||
benchCases("baseline", baseline); | ||
benchCases("current", current); | ||
|
||
suite.on("cycle", report).run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters