Zero filled array creation (v20)

Revision 20 of this benchmark created by wertogg on


Test runner

Ready to run.

Testing in
TestOps/sec
Array Apply
Array.apply(null, new Array(100)).map(Number.prototype.valueOf,0);
ready
Array Join/Split String
new Array(5+1).join('0').split('')
ready
Array Join Split Number
new Array(5+1).join('0').split('').map(parseFloat)
ready
Array Apply Number
Array.apply(null, new Array(5)).map(Number.prototype.valueOf,0);
ready
Array Apply String
Array.apply(null, new Array(3)).map(String.prototype.valueOf,"hi")
ready
Array push
for (var i = 0, a = []; i < 100; i++) a.push(0);
ready
Array assign
for (var i = 0, a = new Array(100); i < 100;) a[i++] = 0;
ready
Typed array conversion
[].slice.call(new Uint8Array(100));
ready
Binary concatenation
for (var i = 100, a = [], add = [0]; i; i >>=1) {
    if (i & 1) a.push.apply(a, add);
    add.push.apply(add, add);
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.