RegExp test / search / match vs. indexOf

JavaScript performance comparison

Revision 46 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var str1 = 'key';
  var str2 = 'key,value';
  var str3 = 'key:value';
  

};
</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
test
/[,:]/.test(str1);
/[,:]/.test(str2);
/[,:]/.test(str3);
pending…
search
str1.search(/[,:]/);
str2.search(/[,:]/);
str3.search(/[,:]/);
pending…
indexOf
~str1.indexOf(',') || ~str1.indexOf(':');
~str2.indexOf(',') || ~str2.indexOf(':');
~str3.indexOf(',') || ~str3.indexOf(':');
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