RegExp vs indexOf (v22)

Revision 22 of this benchmark created on


Description

Compare speed of Regex with indexOf for finding matching text in string.

Setup

var link = "https://www.youtube.com/";

Test runner

Ready to run.

Testing in
TestOps/sec
Regex
/^http/.test(link);
 
ready
indexOf
link.indexOf("http") > -1;
ready
link.startsWith("http")
ready

Revisions

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