Character class

JavaScript performance comparison

Test case created by Ted Hopp

Info

Test positive match of character class vs negative match of complement.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var nospecial=/^[^*|\":<>[\]{}`\\()';@&$]+$/;
    var special=/[*|\":<>[\]{}`\\()';@&$]/;
    var address = "This is an address";
    var address2 = "This is an address@work";
   
};
</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
no special
address.match(nospecial);
address2.match(nospecial);
pending…
special
address && special.test(address);
address2 && special.test(address2);
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