RegExp test vs. Match (v27)

Revision 27 of this benchmark created on


Preparation HTML

<script>
  var strings = [];
  for (var i = 0; i < 500; ++i) {
   strings[i] = "The end of the beginning? Or the beginning of the end?";
  }
  
  var regex1 = /beginning/,
      regex2 = /(end of).*(end)/,
      regex3 = /beginnizg/;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Match
var list = [];
for (var i = 0; i < strings.length; ++i) {
 var b = strings[i].match(regex1),
     b2 = strings[i].match(regex2),
     b3 = strings[i].match(regex3);
 list.push(b || b2 || b3);
}
ready
Test
var list = [];
for (var i = 0; i < strings.length; ++i) {
 var b = regex1.test(strings[i]);
regex1.lastIndex = 0;
     b2 = regex2.test(strings[i]);
regex2.lastIndex = 0;
     b3 = regex3.test(strings[i]);
regex3.lastIndex = 0;

 list.push(b || b2 || b3);
}
ready

Revisions

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