Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Javascript Array sorting performance with sort() and reduce() take2
(version: 0)
Javascript Array sorting performance with sort() and reduce()
Comparing performance of:
with reduce() vs with sort()
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id='min-data'></div>
Tests:
with reduce()
const div = document.getElementById('min-data'); const newArray = []; for(let i = 0; i < 10000000; i++){ const num = Math.floor(Math.random() * 10000000); newArray.push(num); } newArray.reduce((a, b) => (a < b ? a : b), []); div.innerHTML = newArray[0].toString();
with sort()
const div = document.getElementById('min-data'); const newArray = []; for(let i = 0; i < 10000000; i++){ const num = Math.floor(Math.random() * 10000000); newArray.push(num); } newArray.sort((a, b) => a - b); div.innerHTML = newArray[0].toString();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
with reduce()
with sort()
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0
Browser/OS:
Firefox 139 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
with reduce()
1.0 Ops/sec
with sort()
1.3 Ops/sec
Related benchmarks:
sort vs reduce
sort vs reduce
sort vs reduce for a few elements
sort vs reduce v2
sort vs reduce v3
Comments
Confirm delete:
Do you really want to delete benchmark?