Push vs length (v4)

Revision 4 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
length
var myArray = [];

for (var i = 0; i < 100; i++) {
  myArray[myArray.length] = 'foo';
  myArray[myArray.length] = 'bar';
}
myArray.join("");
ready
push
var myArray = [];

for (var i = 0; i < 100; i++) {
  myArray.push('foo');
  myArray.push('bar');
}
myArray.join("");
ready
append
var str = "";

for (var i = 0; i < 100; i++) {
  str += 'foo';
  str += 'bar';
}
ready

Revisions

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