Prefix or Postfix increment?
JavaScript performance comparison
Info
So with recent JS runtimes, does using the prefix increment/decrement operators squeeze the usual performance droplet from loop index maintenance?
Preparation code
<script>
var data = new Array(500 * 1000);
var index = data.length - 1;
while (index--) data[index] = index;
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Prefix |
|
pending… |
Suffix |
|
pending… |
Crockford |
|
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 Christophe
- Revision 3: published by Aalok Shah
- Revision 4: published
- Revision 5: published by uupaa
- Revision 6: published by imaya
- Revision 7: published
- Revision 8: published by gfx
- Revision 9: published
- Revision 10: published
- Revision 11: published by Matthew Crumley
- Revision 12: published by Matthew Crumley
- Revision 13: published by elv1s
- Revision 14: published by zaus
- Revision 15: published
- Revision 16: published by Huan Li
- Revision 17: published
- Revision 18: published
- Revision 19: published
- Revision 20: published by Hyzhak
0 comments