Script Preparation code:
x
 
window.arr = [5,3,8,4,6]
window.bubbleSort = (arr) => {
    for(let i = 0; i < arr.length; i++){
        for(let j = 0; j < arr.length - i - 1; j++){
            if(arr[j + 1] < arr[j]){
                [arr[j + 1],arr[j]] = [arr[j],arr[j + 1]]
            }
        }
    };
    return arr;
}
window.insertionSort = (arr) => {
    for(let i = 1; i < arr.length;i++){
        for(let j = i - 1; j > -1; j--){
            if(arr[j + 1] < arr[j]){
                [arr[j+1],arr[j]] = [arr[j],arr[j + 1]];
            }
        }
    };
  return arr;
}
Tests:
  • bubbleSort

     
    window.bubbleSort(window.arr);
  • Insertion Sort

     
    window.insertionSort(window.arr);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    bubbleSort
    Insertion Sort

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Chrome 106 on Windows
View result in a separate tab
Test name Executions per second
bubbleSort 1878384.5 Ops/sec
Insertion Sort 1738188.5 Ops/sec