Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
.sort() vs Math.min / Math.max
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/120.0.0.0 Safari/537.36 OPR/106.0.0.0
Browser:
Opera 106
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Array.sort
3008409.0 Ops/sec
Math min and max
3677622.8 Ops/sec
Script Preparation code:
const arr = [2,35,67,3,7,58,433,13,23,1];
Tests:
Array.sort
const arr = [2,35,67,3,7,58,433,13,23,1]; const a = arr.sort(); const min = a[0]; const max = a[1];
Math min and max
const arr = [2,35,67,3,7,58,433,13,23,1]; const min = Math.min(...arr); const max = Math.max(...arr);