Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Sorting test
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
custom sort
333163.3 Ops/sec
normal sort
326950.4 Ops/sec
Tests:
custom sort
const array1 = [1, 3, 9]; const array2 = [2, 9, 4]; let array = mergeSort(array1, array2); console.log(array); function mergeSort(array1, array2) { //comparing two popular merging techniques spread is slightly faster so that's being used //merge arrays let mergedArray = [...array1, ...array2]; //sort arrays // loop through array for (let i = 0; i < mergedArray.length - 1; i++) { //set first index let min = i; //loop through array again for (let j = i + 1; j < mergedArray.length; j++) { //check if number in first array is smaller if reset index if (mergedArray[j] < mergedArray[min]) { min = j; } } //if index of first for has been reset above it's diffirent which means we can add it to end of the array if (min != i) { let target = mergedArray[i]; mergedArray[i] = mergedArray[min]; mergedArray[min] = target; } } return mergedArray; //return mergedArray.sort((a,b) => a-b); }
normal sort
const array1 = [1, 3, 9]; const array2 = [2, 9, 4]; let array = mergeSort(array1, array2); console.log(array); function mergeSort(array1, array2) { //comparing two popular merging techniques spread is slightly faster so that's being used //merge arrays let mergedArray = [...array1, ...array2]; //sort arrays return mergedArray.sort((a,b) => a-b); }