Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
map vs reduce
Transform all elements from an array to a new array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 SberBrowser/33.0.0.0
Browser:
Chrome 141
Operating system:
Windows
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
map
8056278.5 Ops/sec
reduce
11859620.0 Ops/sec
reduce, defined accu length
29138838.0 Ops/sec
reduce push
11296674.0 Ops/sec
reduce concat
223520.5 Ops/sec
Script Preparation code:
var array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; var callback = x => x * 2;
Tests:
map
array.map(callback);
reduce
array.reduce((acc, x, index) => (acc[index] = callback(x), acc), [])
reduce, defined accu length
array.reduce((acc, x, index) => (acc[index] = callback(x), acc), new Array(array.length))
reduce push
array.reduce((acc, x, index) => (acc.push(callback(x)), acc), []);
reduce concat
array.reduce((acc, x) => acc.concat(callback(x)), []);