Add timing

This commit is contained in:
Andrew Morris
2022-12-21 09:31:40 +11:00
parent 50c54a4697
commit 14270f11f2

View File

@@ -128,9 +128,13 @@ editorEl.innerHTML = "";
renderJob(runJob, outcomeEl);
function renderJob(job: Job<string>, el: HTMLElement) {
const loadingTimerId = setTimeout(() => {
const startTime = Date.now();
const loadingInterval = setInterval(() => {
if (currentUpdateId === updateId) {
vsmEl.textContent = "Loading...";
el.textContent = `Loading... ${
((Date.now() - startTime) / 1000).toFixed(1)
}s`;
}
}, 100);
@@ -149,7 +153,7 @@ editorEl.innerHTML = "";
el.classList.add("error");
}
} finally {
clearTimeout(loadingTimerId);
clearInterval(loadingInterval);
}
})();
}