Reduce callbacks immutability: Array accumulator (v3)

Revision 3 of this benchmark created on


Setup

const power = 2;  
const size = 10 ** power;
const data = new Array(size);
for (i=0; i<size; i++) data[i] = i;

Test runner

Ready to run.

Testing in
TestOps/sec
Mutability
var result = data.reduce(
	(accumulator, item, index) => {
		accumulator.push(item);
		return accumulator;
	},
	[]
);	

ready
Immutability
var result = data.reduce(
	(accumulator, item, index) => {
		return [...accumulator, item];
	},
	[]
);
ready

Revisions

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