Capturing groups vs non-capturing groups

JavaScript performance comparison

Test case created by Federico

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var text = "some say hello,some say bye, or ola or cheers!'";
  

};
</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
Multiple capturing groups
var patt = new RegExp("(hello)|(bye)|(ola)|(cheers)");
patt.test(text);
pending…
One capturing group
var patt = new RegExp("(hello|bye|ola|cheers)");
patt.test(text);
pending…
Non-capturing groups
var patt = new RegExp("(?:hello|bye|ola|cheers)");
patt.test(text);
pending…
No groups
var patt = new RegExp("hello|bye|ola|cheers");
patt.test(text);
pending…

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

0 Comments