Open xgqfrms opened 5 years ago
https://developer.mozilla.org/en-US/docs/Web/API/Console/time
https://developer.mozilla.org/en-US/docs/Web/API/Console/timeEnd
// no necessary label, the default label is `default`
let log = console.log;
console.time();
log("Click to continue");
console.timeLog();
log("Do a bunch of other stuff...");
console.timeEnd();
let log = console.log;
console.time("answer time");
log("Click to continue");
console.timeLog("answer time");
log("Do a bunch of other stuff...");
console.timeEnd("answer time");
demo
https://github.com/Advanced-Frontend/Daily-Interview-Question
https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/253
function wait() {
return new Promise(resolve =>
setTimeout(resolve, 10 * 1000)
)
}
async function main() {
console.time();
await wait();
await wait();
await wait();
console.timeEnd();
}
main();
// Promise {<pending>}
// default: 30001.47412109375ms
timer & console
timer
https://developer.mozilla.org/en-US/docs/Archive/Add-ons/Code_snippets/Timers
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
https://developer.mozilla.org/en-US/docs/Web/API/console/assert
https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
IDLE
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/idle
https://www.cnblogs.com/xgqfrms/p/11433168.html
https://alligator.io/js/console-time-timeend/ https://flaviocopes.com/requestanimationframe/ https://css-tricks.com/using-requestanimationframe/ http://javascriptkit.com/javatutors/requestanimationframe.shtml
https://developers.google.com/web/updates/2012/08/When-milliseconds-are-not-enough-performance-now
console
https://developer.mozilla.org/en-US/docs/Web/API/Console
https://developer.mozilla.org/en-US/docs/Web/API/console#Timers