Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Versions of Quick Sort vs. .sort
(version: 0)
Comparing performance of:
quickSort vs quickSort2 vs built in sort
Created:
5 years ago
by:
Guest
Jump to the latest result
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 });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
quickSort
quickSort2
built in sort
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0
Browser/OS:
Firefox 134 on Ubuntu
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
quickSort
2465510.5 Ops/sec
quickSort2
273207392.0 Ops/sec
built in sort
86784912.0 Ops/sec
Related benchmarks:
Versions of Quick Sort
quicksort for vs while
for vs while vs filter in quicksort
Quick Sort
Comments
Confirm delete:
Do you really want to delete benchmark?