regexp.test vs string.match

Benchmark created on


Setup

const url='https://www.google.com/matchthis/other/args';
const regexpInstance = /matchthis/;

Test runner

Ready to run.

Testing in
TestOps/sec
regexp.test()
/matchthis/.test(url);
ready
string.match() with new regexp instance
url.match(/matchthis/);
ready
includes
url.includes('matchthis');
ready
indexOf
url.indexOf('matchthis') >= 0;
ready
string.match() with initialized regexp
url.match(regexpInstance);
ready
string.match() with string
url.match('matchthis');
ready
regexpInstance.test()
regexpInstance.test(url);
ready

Revisions

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