Created
September 1, 2017 14:26
-
-
Save oussla/0c9be3e537d4bf08535dc24b8019b46a to your computer and use it in GitHub Desktop.
LoadTimes – Simple function to calculate the various load times available in window.chrome.loadTimes()
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
/** | |
LoadTimes | |
Simple function to calculate the various load times available in window.chrome.loadTimes(). | |
Rounds values as milliseconds, relatives to "startLoadTime". | |
Result is stored on clipboard. | |
*/ | |
console.info("LoadTimes"); | |
var theTimes = {}; | |
for(prop in window.chrome.loadTimes()) { | |
theTimes[prop] = window.chrome.loadTimes()[prop]; | |
if(window.chrome.loadTimes()[prop] !== false && window.chrome.loadTimes()[prop] !== null && typeof(window.chrome.loadTimes()[prop]) !== "string") { | |
theTimes[prop + "_relative"] = Math.round((window.chrome.loadTimes()[prop] - window.chrome.loadTimes().startLoadTime) * 1000); | |
console.info(" - " + prop + ": " + theTimes[prop + "_relative"]); | |
} | |
} | |
copy(theTimes); | |
console.info("LoadTimes: times copied in clipboard."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment