Regex string vs precompiled (v2)

Revision 2 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, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. '

Test runner

Ready to run.

Testing in
TestOps/sec
On the fly
const regex = new RegExp(source, 'ui')

for (let i = 0; i < 3000; i++) {
    regex.test(string)
    string += i
}
ready
Precompiled
for (let i = 0; i < 3000; 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.