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; rv:139.0) Gecko/20100101 Firefox/139.0
Browser:
Firefox 139
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
11 months ago
Test name
Executions per second
with reduce()
1.0 Ops/sec
with sort()
1.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();