Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
flatMap() vs filter().map() vs for of loop
(version: 0)
flatMap vs filter map
Comparing performance of:
filter().map() vs flatMap() vs for of loop
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = []; var i = 0; while (i <= 1E5) arr[i] = i++;
Tests:
filter().map()
arr.filter(x => x % 3).map(x => x/100)
flatMap()
arr.flatMap(x => x % 3 ? x/100 : [])
for of loop
const results = []; for (const x of arr) { if (x % 3) { results.push(x/100); } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
filter().map()
flatMap()
for of loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser/OS:
Chrome 129 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
filter().map()
269.4 Ops/sec
flatMap()
318.7 Ops/sec
for of loop
627.5 Ops/sec
Related benchmarks:
flatMap() vs filter().map() vs for loop accumulator
flatMap() vs filter().map() vs reduce vs for
flatMap() vs map().filter() v1
flatMap() vs filter().map() 2
flatMap() vs filter().map() vs for..of
flatMap() vs filter().map() vs reduce() v8
flatMap() vs filter().map() 1
Comments
Confirm delete:
Do you really want to delete benchmark?