Size of string in RegEx match

JavaScript performance comparison

Test case created by erosman

Info

Checking the effect of the Size of the String in a RegEx match

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var str = 'jsPerf aims to provide an easy way to create and share test cases, comparing the performance of different JavaScript snippets by running benchmarks. For more information, see the FAQ.';
   
    var str10 = Array(10).join(str);
    var str1000 = Array(1000).join(str);
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
smaller str global
var thisTest = str10.match(/to/gi);
pending…
larger str global
var thisTest = str1000.match(/to/gi);
pending…
smaller str non-global
var thisTest = str10.match(/to/i);
pending…
larger str non-global
var thisTest = str1000.match(/to/i);
pending…
smaller str non-global pattern
var thisTest = str10.match(/\w{3,5}/i);
pending…
larger str non-global pattern
var thisTest = str1000.match(/\w{3,5}/i);
pending…
smaller str non-global patt non-match
var thisTest = str10.match(/\W{3,5}/i);
pending…
larger str non-global patt non-match
var thisTest = str1000.match(/\W{3,5}/i);
pending…

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

Compare results of other browsers

0 comments

Add a comment