Skip to content

Instantly share code, notes, and snippets.

@oussla
Created September 1, 2017 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oussla/0c9be3e537d4bf08535dc24b8019b46a to your computer and use it in GitHub Desktop.
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()
/**
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