push allocated vs dynamic (v35)

Revision 35 of this benchmark created on


Description

is it usefull to pre-allocate the array by setting the last value first when assigning some values ?

Setup

var n = 10000;
    var myArray = [];

Test runner

Ready to run.

Testing in
TestOps/sec
push
for (var i = 0; i < n; i++) {
  myArray.push(i)
}
ready
reverse writing
var _this = this;
var config = ['12', '#151510', '#A4A4A4', '#619EC0', '#1B1B1A', '#212323', '#75B9DF', '#A0A0A0', '#818B9B', '0.8', '#8F9FB3'];
for (var i = 0; i < _this.config.length; i++) {}
ready
reverse writing, array allocated with Array constructor
  var i = n;
  while (i--) {
    myArray[i] = i
  }
ready

Revisions

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