Cache RegExp or new exp
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var regex = new RegExp(/^(contact|billing|delivery)_(company_name|name|lastname|email|acode_home|acode_work|phone_home|phone_work|phone_mobile|address_1|address_2|zip_suburb|suburb|state|zip|country)/);
var regex2 = /^(contact|billing|delivery)_(company_name|name|lastname|email|acode_home|acode_work|phone_home|phone_work|phone_mobile|address_1|address_2|zip_suburb|suburb|state|zip|country)/;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Cache RegExp |
|
pending… |
New each time |
|
pending… |
No new Regexp |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments