Skip to content

Instantly share code, notes, and snippets.

@simontabor
Created May 13, 2012 12:48
Show Gist options
  • Save simontabor/2688307 to your computer and use it in GitHub Desktop.
Save simontabor/2688307 to your computer and use it in GitHub Desktop.
Find the connection time and response time for easy server monitoring.
try {
// connecttime is the time taken for the user agent to establish a connection to the server.
var connecttime = window.performance.timing.connectEnd - window.performance.timing.connectStart;
console.log('Connect Time: '+connecttime+'ms');
// responsetime is the time difference between recieving the first byte of data and the last byte from the server.
var responsetime = window.performance.timing.responseEnd - window.performance.timing.responseStart;
console.log('Response Time: '+responsetime+'ms');
}
catch(e) {
// some complicated shit can go on here to get the details the hard way... probably
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment