Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
.sort vs manual (in the context of making a res. array)
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/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
loop
378140.2 Ops/sec
.sort
216208288.0 Ops/sec
Tests:
loop
const arr = [10, 2, 5, 110, 1, 9, 11]; let res = [] for (let i = 0; i < arr.length; i++) { for (let j = 0; j < arr.length; j++) { if (arr[i] <= res[j]) { res.splice(j,0,arr[i]); break; } } if (arr[i] > res[res.length-1] || res.length == 0) { res.push(arr[i]); } } console.log(res)
.sort
const arr = [10, 2, 5, 110, 1, 9, 11]; const sortNumbers = (arr) => { console.log([...arr].sort((a, b) => a - b)); };