Push vs length (v5)

Revision 5 of this benchmark created on


Test runner

Ready to run.

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

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

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

for (var i = 0; i < 100000; 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.