Array copy (v2)

Revision 2 of this benchmark created on


Description

Cloning arrays.

Setup

var acc = 0;
var W = 100;
var size = W * W;
var typed = new Int32Array(size);
crypto.getRandomValues(typed);
var array = [...typed];

Test runner

Ready to run.

Testing in
TestOps/sec
TypedArray (sum)
const typed2 = typed.slice();
for (let x = 0; x < size; x++) {
  acc += typed2[x];
}
ready
TypedArray (random)
const typed2 = typed.slice();
const len = typed2.length;
acc += typed2[Math.floor(Math.random() * len)];
ready

Revisions

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