Regex string vs precompiled (v3)

Revision 3 of this benchmark created on


Setup

const source = 'password|passwort|kennwort|wachtwoord|mot de passe|clave|contraseña|lösenord' + '|something more'
const precompiled = /password|passwort|kennwort|wachtwoord|mot de passe|clave|contraseña|lösenord|something more/iu

let string = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit'

Test runner

Ready to run.

Testing in
TestOps/sec
On the fly
for (let i = 0; i < 10000; i++) {
	const regex = new RegExp(source, 'ui')
    regex.test(string)
    string += i
}
ready
Precompiled
for (let i = 0; i < 10000; i++) {
    precompiled.test(string)
    string += i
}
ready

Revisions

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