Regex reuse test

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Reusing literal
const r = /abc/;

for (let i = 0; i < 1_000_000; i++) {
	r.test("abc");
}
ready
Reusing constructor
const r = new RegExp('abc');

for (let i = 0; i < 1_000_000; i++) {
	r.test("abc");
}
ready
New literal
for (let i = 0; i < 1_000_000; i++) {
	const r = /abc/;
	r.test("abc");
}
ready
New constructor
for (let i = 0; i < 1_000_000; i++) {
	const r = new RegExp('abc');
	r.test("abc");
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.