for vs map (v6)

Revision 6 of this benchmark created on


Setup

let a = new Array(100)
for (let i = 0; i < a.length; i++) {
	a[i] = (i + 10) * (i + 2)
}

function myFn(n) {
	return { 
		type: 'div', 
		children: ['item' + n]
	}
}

Test runner

Ready to run.

Testing in
TestOps/sec
builtin map
let x = a.map(myFn)
ready
fastmap
function fastmap(list, fn) {
	let output = new Array(list.length)
	for (let i = 0; i < list.length; i++) {
		output[i] = fn(list[i])
	}
	return output
}

let x = fastmap(a, myFn)
ready

Revisions

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