Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
forEach vs reduce
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser:
Firefox 146
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
forEach
376758.1 Ops/sec
reduce
536424.4 Ops/sec
reduce spread
113393.2 Ops/sec
Script Preparation code:
var a = Array.from({length:100},()=>Math.random()); var b = [];
Tests:
forEach
a.forEach(e=>{if (e>0.5) b.push(e)});
reduce
b = a.reduce((a,c)=>c>0.5?a.concat(c):a,[])
reduce spread
b = a.reduce((a,c)=>c>0.5?[...a,c]:a,[])