RegExp test / search / match vs. indexOf

JavaScript performance comparison

Revision 41 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var str = 'INLINE-block(_ru.by_ruby)',
    arr = ['inline', 'inline-block', 'inline-table', 'ruby'],
    obj = {
      'inline': true,
      'inline-block': true,
      'inline-table': true,
      'ruby': true
    },
    findThis = /(inline|ruby)/gi;

};
</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
findThis.test(str);
pending…
search
str.search(findThis) > -1;
pending…
exec
findThis.exec(str);
pending…
match()
str.match(findThis) > 0;
pending…
indexOf()
str.indexOf(findThis) > -1;
pending…
string search
str.search('inline') > -1 && str.search('ruby') > -1;
pending…
string indexOf
str.indexOf('inline') > -1 && str.indexOf('ruby') > -1;
pending…
string match
str.match('inline') > -1 && str.match('ruby') > -1;
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