Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
flatMap() vs filter().map() vs reduce() vs forOf loop v8
(version: 1)
flatMap vs filter map vs reduce() vs forOf loop
Comparing performance of:
filter().map() vs flatMap() vs reduce() vs forof loop
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = []; var i = 0; while (i <= 10000) arr[i] = i++;
Tests:
filter().map()
arr.filter(x => x % 2).map(x => x/100)
flatMap()
arr.flatMap(x => x % 2 ? x/100 : [])
reduce()
arr.reduce((newArray, x) => { if (x % 2) { newArray.push(x / 100) } return newArray }, [])
forof loop
newArray = []; for (x of arr){ if (x % 2) { newArray.push(x / 100) } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
filter().map()
flatMap()
reduce()
forof loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:148.0) Gecko/20100101 Firefox/148.0
Browser/OS:
Firefox 148 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
filter().map()
14592.2 Ops/sec
flatMap()
10222.8 Ops/sec
reduce()
23724.7 Ops/sec
forof loop
5790.1 Ops/sec
Related benchmarks:
flatMap() vs filter().map() vs reduce() v2
flatMap() vs filter().map() vs reduce() - filtered 1 time out of 10 - small array
flatMap() vs filter().map() vs reduce vs for
flatMap() vs filter().map() vs reduce() ONE FILTER
flatMap() vs filter().map() vs reduce
flatMap() vs filter()x1.map() vs reduce()
Ctrl: flatMap() vs filter().map() vs reduce()
flatMap() vs filter().map() vs reduce() test
flatMap() vs filter().map() vs reduce() v8
Comments
Confirm delete:
Do you really want to delete benchmark?