map => is VERY slow!

Benchmark created on


Setup

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

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

Test runner

Ready to run.

Testing in
TestOps/sec
map & closure
a.map(item => mappedFn(item))
ready
plain code
let fn = mappedFn;
let o = new Array(a.length)
for (let i = 0; i < a.lenght; i++) {
	let data = a[i];
	o[i] = fn(data)
}
ready

Revisions

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