regexp test vs indexOf

JavaScript performance comparison

Revision 97 of this test case created by Fergal

Preparation code

<script>

var needle = "bar",
    stack = "foo bar joe doe"



</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Regexp test
var regexp = new RegExp(needle, "i");
regexp.test(stack);
pending…
indexOf toLowerCase
stack.toLowerCase().indexOf(needle.toLowerCase());
pending…
Regexp search
var regexp = new RegExp(needle, "i");
stack.search(regexp);
pending…
Regexp exec
var regexp = new RegExp(needle, "i");
regexp.exec(stack);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment