array.values.map vs array.map (v3)

Revision 3 of this benchmark created on


Setup

var count = 10000*1000

Test runner

Ready to run.

Testing in
TestOps/sec
simple map
const array = []
for(let i = 0; i < count ; i++) {
	array[i] = i;
}

const array1 = array.map((i) => i)
ready
values().map
const array = []
for(let i = 0; i < count ; i++) {
	array[i] = i;
}

const array1 = array.values().map((i) => i).toArray()
ready
values().map + predefined array
const array = new Array(count);
for(let i = 0; i < count ; i++) {
	array[i] = i;
}

const array1 = array.values().map((i) => i).toArray()
ready
foo loop
const array = new Array(count);
const array1 = new Array(count);
for(let i = 0; i < count ; i++) {
	array[i] = i;
}

const iterator = array.values()
let counter = 0;
for(let v of iterator ) {
	array1[counter++] = v;
}
ready
simple for loop
const array = new Array(count);
const array1 = new Array(count);
for(let i = 0; i < count ; i++) {
	array[i] = i;
}

for(let i = 0; i < count ; i++) {
	array1[i] = array[i];
}
ready

Revisions

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