Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Sorted vs unsorted Array sort
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Chrome OS 14541.0.0
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
Sorted with check
24K/s
Sorted without check
2K/s
Unsorted
216/s
Unsorted with check
175/s
View exact numbers
Test name
Executions per second
✓
Sorted with check
23,828 Ops/sec
Sorted without check
2,419 Ops/sec
Unsorted
216 Ops/sec
Unsorted with check
175 Ops/sec
Script Preparation code:
var arr1 = []; for(let i = 0; i < 10000; i++) { arr1.push(Math.floor(Math.random() * 5000)); } var arr2 = arr1.slice(0); arr2.sort((a, b) => a - b);
Tests:
Unsorted
var toSort = arr1.slice(0); toSort.sort((a, b) => a - b);
Sorted with check
var toSort = arr2.slice(0); let lastEntry; let isSorted = true; for(const entry of toSort) { if(lastEntry != null && entry < lastEntry) { isSorted = false; break; } lastEntry = entry; } if(!isSorted) { toSort.sort((a, b) => a - b); }
Sorted without check
var toSort = arr2.slice(0); toSort.sort((a, b) => a - b);
Unsorted with check
var toSort = arr1.slice(0); let lastEntry; let isSorted = true; for(const entry of toSort) { if(lastEntry != null && entry < lastEntry) { isSorted = false; break; } lastEntry = entry; } if(!isSorted) { toSort.sort((a, b) => a - b); }