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:
8 months ago
by:
Guest
Go 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:
8 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
reduce
135/s
filter+map
101/s
View exact numbers
Test name
Executions per second
✓
reduce
135 Ops/sec
filter+map
101 Ops/sec
Related benchmarks
.filter().map() vs .reduce test
reduce vs filter+map
Filter and Map vs Reduce
Array.find vs Array.filter on large dataset
Comments
Confirm delete:
Do you really want to delete benchmark?