Array Assignment vs Array Push
JavaScript performance comparison
Info
You've heard the rumors - now here's the proof.
v3 adds pre-allocation
Preparation code
<script>
Benchmark.prototype.setup = function() {
var size = 2000;
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
arrayA[i] = 'foo'; |
|
pending… |
arrayB.push('foo'); |
|
pending… |
arrayC[i] = 'foo'; (preallocated) |
|
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 Rick Waldron and last updated
- Revision 2: published by mrgnou
- Revision 3: published
- Revision 4: published by Timo
- Revision 5: published by Nige White
0 comments