Initialise array with zeros
JavaScript performance comparison
Info
Create an array of predefined length filled entirely with zeros.
Preparation code
<script>
// Final array will be 1,000,000 elements long
var i, arr,
zeros = (function () {
var i = Math.ceil(Math.random() * 1000),
zs = [];
while (i--) zs.push(0);
return zs
})(),
total_zeros = 1e6,
num_zeros = total_zeros - zeros.length;
alert(num_zeros);
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Push |
|
pending… |
Index - reverse fill |
|
pending… |
Index |
|
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 Paul
- Revision 2: published by Göran Andersson
- Revision 4: published by Pointy
- Revision 5: published
- Revision 6: published
- Revision 7: published
- Revision 9: published by Timo
- Revision 10: published by Timo
- Revision 11: published by Timo
- Revision 12: published by Timo
- Revision 13: published
0 comments