substr vs regex file extension
JavaScript performance comparison
Info
For when you're testing a string for a specific filetype.
Preparation code
<script>
Benchmark.prototype.setup = function() {
var regex = /\.json$/i
, filename = 'example.json';
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
regex |
|
pending… |
substr |
|
pending… |
substr - i |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by ryanve
- Revision 2: published
- Revision 4: published by benoitz
- Revision 5: published by Loadx
- Revision 6: published by George
- Revision 7: published
0 comments