The code is kinda complicated and I don't like the way it interacts
I am going to make a more streamlined version
Highlighted Code
function measureExecutionTime(func) {
var startTime = performance.now();
func();
var endTime = performance.now();
return endTime - startTime;
}
3rd and final
I finally like how it looks and how it works
It displays the times of the different algorithms
Code Complexity is improved by a lot
Highlighted Code
function displayTime(functionName, time) {
var timeDiv = document.getElementById('times');
var timeDisplay = document.createElement('div');
timeDisplay.innerHTML = `${functionName}: ${time.toFixed(2)}ms`; // Display time in milliseconds with 2 decimal places
timeDiv.appendChild(timeDisplay);
}
1st try
Highlighted Code
2nd try
Highlighted Code
3rd and final
Highlighted Code