re new vs direct func

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var re = /\basdf\b/;
    var re2 = new RegExp('(\\s|^)'+'asdf'+'(\\s|$)');
};
</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
re
re.test('asdf');
re.test('asdf ');
re.test(' asdf');
re.test(' asdf ');
re.test(' asdfb ');
re.test(' basdf ');
 
pending…
re2
re2.test('asdf');
re2.test('asdf ');
re2.test(' asdf');
re2.test(' asdf ');
re2.test(' asdfb ');
re2.test(' basdf ');
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