Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Javascript Array sorting performance with sort() and reduce() take2
Javascript Array sorting performance with sort() and reduce()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Browser:
Chrome 125
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
with reduce()
0.5 Ops/sec
with sort()
0.3 Ops/sec
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();