Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
filter.map vs flatmap vs reduce vs flatmap precreated array and filter always true v2
(version: 0)
Comparing performance of:
flatmap vs reduce vs filter.map true vs filter.map with condition
Created:
3 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var arr = []; var i = 0; while (i <= 1E5) arr[i] = i++;
Tests:
flatmap
const preArr = [] arr.flatMap(x => x % 12 && x % 5 && x % 3 ? x/100 : preArr)
reduce
arr.reduce((newArray, x) => { if (x % 12 && x % 5 && x % 3) { newArray.push(x / 100) } return newArray }, [])
filter.map true
arr.filter(x => true).map(x => x/100)
filter.map with condition
arr.filter(x => x % 12 && x % 5 && x % 3).map(x => x/100)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
flatmap
reduce
filter.map true
filter.map with condition
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
javascript array.filter().map() vs array.flatMap()
Array flatMap() vs filter().map()
flatMap() vs filter().map() - arrays
flatMap vs reduce vs loop filtering vs filter/map performance
Reduce Push vs. flatMap vs 123
Comments
Confirm delete:
Do you really want to delete benchmark?