Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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
Benchmark engine:
Benchmark.js
Math min and max
3.7M/s
Array.sort
3.0M/s
View exact numbers
Test name
Executions per second
✓
Math min and max
3,677,623 Ops/sec
Array.sort
3,008,409 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);