includes() vs regex.test() (v3)

Revision 3 of this benchmark created on


Setup

const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
const charactersLength = characters.length;

function makeString() {
    let result = '';
    for (let counter = 0, result = ''; counter < 20; counter++) {
      result += characters.charAt(Math.floor(Math.random() * charactersLength));
    }
    return result;
}

Test runner

Ready to run.

Testing in
TestOps/sec
regex.test()
/z/.test(makeString());
ready
includes()
makeString().includes('z');
ready

Revisions

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