console.time()

console.time() is a method used for measuring the time it takes to execute a specific portion of your code. It allows you to mark the beginning and end of a code block you want to measure and then calculates the elapsed time between those points.


//start
console.time("Response time");

alert("Measuring your response time, click the button");

//end
console.timeEnd("Response time");

      

const buttonOpen = document.getElementById("buttonOpen");
const p1 = document.getElementById("p1");

buttonOpen.onclick = function () {
  //start
  console.time("Response time");

  alert("Measuring your response time, click the button");

  //end
  console.timeEnd("Response time");
  p1.innerHTML = "Response time sent to console";
};