Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
sort vs loop to find max
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/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
sort
373707.6 Ops/sec
loop
443860.3 Ops/sec
Tests:
sort
const arr = [12, 3, 500, 40, 66, 22, 123123, 1, 2, -123, 3333] arr.sort((a, b) => a == b ? 0 : a > b ? -1 : 1) const max = arr[0] console.log(max)
loop
const arr = [12, 3, 500, 40, 66, 22, 123123, 1, 2, -123, 3333] let max = 0 for (const num of arr) { if (num > max) max = num } console.log(max)