Loop vs Slice copy (v2)

Revision 2 of this benchmark created on


Setup

var data = [1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9]

Test runner

Ready to run.

Testing in
TestOps/sec
loop copy
var copy = []
for (var j = 0; j < data.length; j++) {
   copy.push(data[j]);
}
ready
splice copy
var copy = data.slice(0);
ready

Revisions

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