indexOf vs search

Benchmark created on


Setup

var str = "hello world, Lorem iPsum dolOr sIt amEt";
    var needle = 'OREM IPSUM DOLOR';
    
    var re = new RegExp(needle, 'i');

Test runner

Ready to run.

Testing in
TestOps/sec
search
str.search(re);
ready
indexOf
str.toLowerCase().indexOf(needle.toLowerCase());
ready

Revisions

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