Created
March 25, 2012 23:55
-
-
Save mattcg/2201732 to your computer and use it in GitHub Desktop.
window.performance PerformanceTiming data dump
This file contains hidden or 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
window.onload = function() { | |
window.setTimeout(function() { | |
var p = window.performance, t, output, ns; | |
if (!p || !p.timing) { | |
output = '<p>Sorry, you browser doesn\'t support the Navigation Timing API.</p>'; | |
} else { | |
t = p.timing; | |
ns = t.navigationStart; | |
output = '<p>Navigation started at ' + new Date(t.navigationStart).toLocaleString() + '</p>'; | |
output += '<p>redirectStart: ' + (t.redirectStart !== 0 ? (t.redirectStart - ns) + 'ms' : 'n/a') + '</p>'; | |
output += '<p>redirectEnd: ' + (t.redirectEnd !== 0 ? (t.redirectEnd - ns) + 'ms' : 'n/a') + '</p>'; | |
output += '<p><strong>Time taken to redirect (if any): ' + (t.redirectEnd !== 0 ? (t.redirectEnd - t.redirectStart) + 'ms' : 'n/a') + '</strong></p>'; | |
output += '<p>fetchStart: ' + (t.fetchStart - ns) + 'ms</p>'; | |
output += '<p>domainLookupStart: ' + (t.domainLookupStart - ns) + 'ms</p>'; | |
output += '<p><strong>Time taken to load data from app cache (if any): ' + (t.domainLookupStart - t.fetchStart) + 'ms</strong></p>'; | |
output += '<p>domainLookupEnd: ' + (t.domainLookupEnd - ns) + 'ms</p>'; | |
output += '<p><strong>Time taken to perform DNS lookup for ' + location.hostname + ': ' + (t.domainLookupEnd - t.domainLookupStart) + 'ms</strong></p>'; | |
output += '<p>connectStart: ' + (t.connectStart - ns) + 'ms</p>'; | |
output += '<p>secureConnectionStart: ' + (t.secureConnectionStart !== 0 ? (t.secureConnectionStart - ns) + 'ms' : 'n/a') + '</p>'; | |
output += '<p>connectEnd: ' + (t.connectEnd - ns) + 'ms</p>'; | |
output += '<p><strong>Time taken to establish TCP connection: ' + (t.connectEnd - t.connectStart) + 'ms</strong></p>'; | |
output += '<p><strong>Time take to establish SSL connection (if any): ' + (t.secureConnectionStart !== 0 ? (t.connectEnd - t.secureConnectionStart) + 'ms' : 'n/a') + '</strong></p>'; | |
output += '<p>requestStart: ' + (t.requestStart - ns) + 'ms</p>'; | |
output += '<p>responseStart: ' + (t.responseStart - ns) + 'ms</p>'; | |
output += '<p><strong>Time taken to send HTTP request: ' + (t.responseStart - t.requestStart) + 'ms</strong></p>'; | |
output += '<p>responseEnd: ' + (t.responseEnd - ns) + 'ms</p>'; | |
output += '<p><strong>Time taken to receive HTTP response: ' + (t.responseEnd - t.responseStart) + 'ms</strong></p>'; | |
output += '<p>domLoading: ' + (t.domLoading - ns) + 'ms</p>'; | |
output += '<p>domInteractive: ' + (t.domInteractive - ns) + 'ms</p>'; | |
output += '<p><strong>Time take to parse the document: ' + (t.domInteractive - t.domLoading) + 'ms</strong></p>'; | |
output += '<p>domContentLoadedEventStart: ' + (t.domContentLoadedEventStart - ns) + 'ms</p>'; | |
output += '<p><strong>Time taken to execute blocking scripts: ' + (t.domContentLoadedEventStart - t.domInteractive) + 'ms</strong></p>'; | |
output += '<p>domContentLoadedEventEnd: ' + (t.domContentLoadedEventEnd - ns) + 'ms</p>'; | |
output += '<p>domComplete: ' + (t.domComplete - ns) + 'ms</p>'; | |
output += '<p>loadEventStart: ' + (t.loadEventStart - ns) + 'ms</p>'; | |
output += '<p><strong>Time taken to load non-blocking document resources (if any): ' + (t.loadEventStart - t.domContentLoadedEventStart) + 'ms</strong></p>'; | |
output += '<p>loadEventEnd: ' + (t.loadEventEnd - ns) + 'ms</p>'; | |
} | |
(document.getElementById('perf-output') || document.body).innerHTML = output; | |
}, 1000); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment