RegExp test / search / match vs. indexOf

JavaScript performance comparison

Revision 15 of this test case created by Michael Sherov

Preparation code

<script>
  var str = 'body';
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var precompiledRegex = /^(inline|ruby)/;

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
regex
precompiledRegex.test(str);
pending…
comparison
str === "inline" || str === "inline-block" || str === "inline-table" || str === "ruby";
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.

0 Comments