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 (X11; Ubuntu; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0
Browser:
Firefox 134
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
quickSort
2465510.5 Ops/sec
quickSort2
273207392.0 Ops/sec
built in sort
86784912.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 });