Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
reduce vs filter+map on one million
(version: 1)
Tests performance between a single reduce and a filter then map
Comparing performance of:
reduce vs filter+map
Created:
5 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
var items = []; for (var i = 0; i < 1000000; i++) { items[i] = { id: i, selected: i % 4 == 0 }; }
Tests:
reduce
items.reduce( ( array, item ) => { if ( item.selected ) { array.push( item.id ); } return array; }, [] );
filter+map
items.filter( x => x.selected ).map( x => x.id );
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
reduce
filter+map
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser/OS:
Chrome 143 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
reduce
134.8 Ops/sec
filter+map
101.4 Ops/sec
Related benchmarks:
Map&filter VS reduce
.filter().map() vs .reduce test
reduce vs filter+map
Object filtered Array loop vs foreach vs map vs while
Search - forEach vs reduce vs map vs filter vs for
filter + map vs reduce 123
Filter and Map vs Reduce
reduce vs map/filter --- filter and reshape
Array.find vs Array.filter on large dataset
Comments
Confirm delete:
Do you really want to delete benchmark?