Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Sort vs reduce with objects
(version: 1)
Sort and reduce when used with an object
Comparing performance of:
Reduce vs Sort
Created:
one year ago
by:
Guest
Go to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var a = Array.from({length:500},()=>{ return {x: Math.random(), y: Math.random()};})
Tests:
Reduce
a.reduce((a,c) => a.x > c.x ? a : c)
Sort
a.sort((a,c) => a.x > c.x ? -1 : 1)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Reduce
Sort
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/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Reduce
1.9M/s
Sort
171K/s
View exact numbers
Test name
Executions per second
✓
Reduce
1,930,260 Ops/sec
Sort
171,250 Ops/sec
Related benchmarks
sort vs reduce
sort vs reduce for a few elements
Comments
Confirm delete:
Do you really want to delete benchmark?