Created
May 13, 2012 12:48
-
-
Save simontabor/2688307 to your computer and use it in GitHub Desktop.
Find the connection time and response time for easy server monitoring.
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
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