Skip to content

Commit

Permalink
add time of function execution
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiMorozov88 committed Nov 18, 2023
1 parent 9f1ff8b commit 2c7d4e9
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getAbsoluteTime() {
return date.getTime();
}
function showResult() {
console.log(getAbsoluteTime());
const timeStart = getAbsoluteTime();
let result;
commentContainer.innerText = '';
commentContainer.classList.remove('comment-container--error');
Expand Down Expand Up @@ -65,7 +65,9 @@ function showResult() {
return;
}
resultContainer.classList.add('calculator__result--calc');
commentContainer.innerText = `Date of calculation: ${getDate()}`;
for (let count = 0; count < 10000000; count++);
const timeFinish = getAbsoluteTime();
commentContainer.innerText = `Date of calculation: ${getDate()}. Time of function execution: ${timeFinish - timeStart} ms`;
console.log(getAbsoluteTime());
}
button.addEventListener('click', showResult);

0 comments on commit 2c7d4e9

Please sign in to comment.