Emptying an array
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var arr = [],
narr;
if (window.narr) {
narr = window.narr
} else {
narr = [];
for (var i = 0, len = 25 * 1024 * 1024; i < len; i++) // runs 25 to 100 times = some mb
{
narr.push('a' + i);
}
}
arr = narr.slice();
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
Setting
.length to 0
|
|
pending… |
Creating a new empty array
|
|
pending… |
Splice
|
|
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.
- Revision 1: published Matijs
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published
- Revision 6: published
- Revision 7: published
- Revision 8: published
- Revision 9: published
- Revision 10: published
- Revision 12: published
- Revision 13: published Yemster
- Revision 14: published mista_k
- Revision 15: published
- Revision 16: published
- Revision 17: published
- Revision 20: published Sergio
- Revision 21: published Matthias Le Brun
- Revision 22: published Callum Locke
- Revision 23: published SunboX
- Revision 24: published SunboX
- Revision 25: published
- Revision 26: published rajat
- Revision 27: published
- Revision 28: published
- Revision 29: published
- Revision 30: published
- Revision 31: published
- Revision 32: published
- Revision 33: published
- Revision 34: published tiriana
- Revision 35: published
- Revision 36: published Petr
0 Comments