Created
May 13, 2021 18:14
-
-
Save wbamberg/cbc44eb037f1fd58f3390a5566f38014 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let last = 0; // last millisecond recorded | |
let lineno = 0; // current output line number | |
const iterations = 15; | |
let count = 0; | |
function timeout() { | |
logline(new Date().getMilliseconds()); | |
count = count + 1; | |
if (count < iterations) { | |
setTimeout(timeout, 0); | |
} | |
} | |
function run() { | |
setTimeout(timeout, 0); | |
} | |
function logline(msec) { // msec can't wrap: run duration > 1 second | |
const newLine = document.createElement("pre"); | |
newLine.textContent = `${pad(lineno++, 2)} ${pad(last, 3)} ${pad(msec, 3)}`; | |
document.getElementById("log").appendChild(newLine); | |
last = msec; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment