0-fill n-size Array (v10)

Revision 10 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
100000 (uninitialised)
var l = 100000, arr = [];

for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
ready
100000 (constructor initialised)
var l = 100000, arr = new Array(l);

for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
ready
100000 (define length)
var l = 100000, arr = [];
arr.length = l;
for (var i = 0; i < l; ++i) {
  arr[i] = 0;
}
ready
100x1000 (uninitialised)
var l = 100, t = 1000, arrOfArr = [];
for (var j = t; j--;) {  
  var arr = [];

  for (var i = 0; i < l; ++i) {
    arr[i] = 0;
  }
  arrOfArr.push(arr);
}
ready
100x1000 (constructor initialised)
var l = 100, t = 1000, arrOfArr = [];
for (var j = t; j--;) {
  var arr = new Array(l);

  for (var i = 0; i < l; ++i) {
    arr[i] = 0;
  }
  arrOfArr.push(arr);
}
ready
100x1000 (define length)
var l = 100, t = 1000, arrOfArr = [];
for (var j = t; j--;) {
  var arr = [];
  arr.length = l;
  for (var i = 0; i < l; ++i) {
    arr[i] = 0;
  }
  arrOfArr.push(arr);
}
ready

Revisions

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