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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser:
Chrome 135
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
with reduce()
0.7 Ops/sec
with sort()
0.2 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();