Sorting of array
Date tested:
8 months ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Test name
Executions per second
Built in sort
3713366.5 Ops/sec
Insertion sort
14889111.0 Ops/sec
Benchmark definition (click to collapse):
Script Preparation code:
const list = [20, 10, 50, 33, 1, 5, 90, 45, 39, 77, 11]; function built_in_sort(arr) { return arr.sort((a, b) => a - b); } //Insertion sort function insertion_sort(ary) { for (var i = 1, l = ary.length; i < l; i++) { var value = ary[i]; for (var j = i - 1; j >= 0; j--) { if (ary[j] <= value) break; ary[j + 1] = ary[j]; } ary[j + 1] = value; } return ary; }
Tests:
Built in sort
built_in_sort([20, 10, 50, 33, 1, 5, 90, 45, 39, 77, 11])
Insertion sort
insertion_sort([20, 10, 50, 33, 1, 5, 90, 45, 39, 77, 11])
Open this result on MeasureThat.net