RegExp vs indexOf (v15)

Revision 15 of this benchmark created on


Description

Compare speed of Regex with indexOf for simple string comparison

Setup

var isPresent = new RegExp('MSN', 'i');
    var url = 'http://create.leadid.local?pid=2iuegu12&msn=23uigqwud';

Test runner

Ready to run.

Testing in
TestOps/sec
RegEx
if (isPresent.test(url)) {}
ready
indexOf
if (-1 !== url.toLowerCase().indexOf('MSN'.toLowerCase())) {}
ready

Revisions

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