Created
November 18, 2020 03:18
-
-
Save varavut/fbb64b7f195bec29529b559a8ac969b6 to your computer and use it in GitHub Desktop.
This file contains 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
(function f() { | |
async function sleep(mills) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
return resolve() | |
}, mills) | |
}) | |
} | |
async function getPerformanceData() { | |
const maxTry = 10; | |
for (let i = 1; i <= maxTry; i++) { | |
var perfEntries = performance.getEntriesByType("navigation"); | |
if (perfEntries && perfEntries.length > 0) { | |
var p = perfEntries[0]; | |
if (p.loadEventEnd > 0 || i == maxTry) { | |
console.log("azq_time_origin", performance.timeOrigin); | |
console.log("azq_performance_timing", JSON.stringify(p.toJSON())); | |
break; | |
} | |
} | |
await sleep(200); | |
} | |
} | |
getPerformanceData(); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment