Reduce

Benchmark created on


Setup

const array = Array.from(new Array(1000000),  () => ({a: Math.round(Math.random() * 1000), b: Math.round(Math.random() * 1000)}))

Test runner

Ready to run.

Testing in
TestOps/sec
Reduce
array.reduce((all, row) => (
	{
		a: all.a + row.a,
		b: all.b + row.b
	}),	{a: 0, b: 0}
)
ready
ForEach
let a = 0;
let b = 0;

array.forEach(item => {
	a += item.a;
	b += item.b;
})
ready

Revisions

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