Compare string.includes with RegExp.test

Benchmark created on


Setup

const value1 = 'WORLD'
const value2 = 'HELLO, WORLD'
const query = 'hello'
const queryRegExp = new RegExp(query, 'i')

Test runner

Ready to run.

Testing in
TestOps/sec
no match with includes
value1.toLowerCase().includes(query.toLowerCase())
ready
no match with test
new RegExp(query, 'i').test(value1)
ready
match with includes
value2.toLowerCase().includes(query.toLowerCase())
ready
match with test
new RegExp(query, 'i').test(value2)
ready
no match with compiled test
queryRegExp.test(value1)
ready
match with compiled test
queryRegExp.test(value2)
ready

Revisions

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