Reduce vs Map

Benchmark created on


Setup


const types = new Map();

types.set('thing', 'THING');
types.set('other', 'OTHER');
types.set('blargh', 'BLARGH');

Test runner

Ready to run.

Testing in
TestOps/sec
Reduce
const reduced = ['thing', 'other', 'blargh'].reduce((result, type) => {
	result.push(types.get(type));
	return result;
}, [])
ready
Map
const mapped = ['thing', 'other', 'blargh'].map(t=>types.get(t))
ready

Revisions

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