Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Versions of Quick Sort vs. .sort
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
quickSort
1751413.0 Ops/sec
quickSort2
153752640.0 Ops/sec
built in sort
130836872.0 Ops/sec
Script Preparation code:
var array = [0, 213, 2, 55312, 322, 1312, 12311123, 54642 ]; function quickSort(arr){ if(arr.length <= 1) return arr const pivot = arr[arr.length - 1] let left = [] let right = [] for(let i = 0; i < arr.length-1; i++){ if (arr[i] < pivot) { left.push(arr[i]) } else { right.push(arr[i]) } } return [].concat(quickSort(left),pivot,quickSort(right)) } function quickSort2(arr){ if(arr.length <= 1) return arr const pivot = arr.pop() let left = [] let right = [] while(arr[0]){ if (arr[0] < pivot) { left.push(arr.shift()) } else { right.push(arr.shift()) } } return [].concat(quickSort(left),pivot,quickSort(right)) }
Tests:
quickSort
quickSort(array);
quickSort2
quickSort2(array);
built in sort
array.sort(function (a, b) { return a - b });