Created
March 19, 2018 07:26
-
-
Save barretlee/b9e0d1d47d6c28acad6acdf44c681ba8 to your computer and use it in GitHub Desktop.
performance
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
var readyStart = timing.fetchStart - timing.navigationStart; | |
var redirectTime = timing.redirectEnd - timing.redirectStart; | |
var appcacheTime = timing.domainLookupStart - timing.fetchStart; | |
var unloadEventTime = timing.unloadEventEnd - timing.unloadEventStart; | |
var lookupDomainTime = timing.domainLookupEnd - timing.domainLookupStart; | |
var connectTime = timing.connectEnd - timing.connectStart; | |
var requestTime = timing.responseEnd - timing.requestStart; | |
var initDomTreeTime = timing.domInteractive - timing.responseEnd; | |
var domReadyTime = timing.domComplete - timing.domInteractive; | |
var loadEventTime = timing.loadEventEnd - timing.loadEventStart; | |
var loadTime = timing.loadEventEnd - timing.navigationStart; | |
console.log('准备新页面时间耗时: ' + readyStart); | |
console.log('redirect 重定向耗时: ' + redirectTime); | |
console.log('Appcache 耗时: ' + appcacheTime); | |
console.log('unload 前文档耗时: ' + unloadEventTime); | |
console.log('DNS 查询耗时: ' + lookupDomainTime); | |
console.log('TCP 连接耗时: ' + connectTime); | |
console.log('Request 请求耗时: ' + requestTime); | |
console.log('请求完毕至 DOM 加载: ' + initDomTreeTime); | |
console.log('解释 DOM 树耗时: ' + domReadyTime); | |
console.log('load 事件耗时: ' + loadEventTime); | |
console.log('从开始至 load 总耗时: ' + loadTime); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment