Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
filter-map vs reduce fixed
modified version of `map-filter vs reduce` that switches the order of operations Original was not fair comparison as it mapped all iterations not just the ones that passed the filter
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0
Browser:
Firefox 132
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
reduce
391K/s
map-filter
238K/s
View exact numbers
Test name
Executions per second
✓
reduce
390,894 Ops/sec
map-filter
237,834 Ops/sec
Script Preparation code:
a=[]; for(i=0;i<1000;i++) a.push(Number(i)/1000); var filtering=x=>(x*114514)%1>0.5; var mapping=x=>x+0.1919; var reducing=(acc,x)=>{ if((x*114514)%1>0.5) acc.push(x+0.1919); return acc; }
Tests:
map-filter
a.filter(filtering).map(mapping);
reduce
a.reduce(reducing,[]);