Array copy (v8)

Revision 8 of this benchmark created on


Description

Cloning arrays

Setup

var W = 100;
var size = W * W;
var typed = new Int32Array(size);
crypto.getRandomValues(typed);
var array = [...typed];
var nested = [];
for (let n = 0; n < W; n++) {
  nested.push(
    [...typed.slice(n * W, (n + 1) * W)]
  );
}
var acc = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
TypedArray
const typed2 = typed.slice();
for (let x = 0; x < size; x++) {
  acc += ++typed2[x];
}
ready
array[]
const array2 = [...array];
for (let x = 0; x < size; x++) {
  acc += ++array2[x];
}
ready
nested[][]
const nested2 = [];
for(let n = 0; n < W; n++)
	nested2[n] = [...nested[n]];
for (let y = 0; y < W; y++) {
  for (let x = 0; x < W; x++) {
    acc += ++nested2[y][x];
  }
}
ready

Revisions

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