性能监控问题
function testPerformance(){ let performance = window.performance let timing = performance.timing console.log('白屏时间',timing.responseEnd - timing.navigationStart) console.log('页面总下载时间.',timing.loadEventEnd - timing.navigationStart) console.log('DNS解析耗时.',timing.domainLookupEnd - timing.domainLookupStart) console.log('TCP链接耗时.',timing.connectEnd - timing.connectStart) console.log('首包请求耗时.',timing.responseEnd - timing.responseStart) console.log('dom解释耗时.',timing.domComplete - timing.domInteractive) console.log('用户可操作时间.',timing.domContentLoadedEventEnd - timing.navigationStart) }
- DNS 解析耗时: domainLookupEnd - domainLookupStart
- TCP 连接耗时: connectEnd - connectStart
- SSL 安全连接耗时: connectEnd - secureConnectionStart
- 网络请求耗时 (TTFB): responseStart - requestStart
- 数据传输耗时: responseEnd - responseStart
- DOM 解析耗时: domInteractive - responseEnd
- 资源加载耗时: loadEventStart - domContentLoadedEventEnd
- First Byte时间: responseStart - domainLookupStart
- 白屏时间: responseEnd - fetchStart
- 首次可交互时间: domInteractive - fetchStart
- DOM Ready 时间: domContentLoadEventEnd - fetchStart
- 页面完全加载时间: loadEventStart - fetchStart
- http 头部大小: transferSize - encodedBodySize
- 重定向次数:performance.navigation.redirectCount
- 重定向耗时: redirectEnd - redirectStart
以自己现在的努力程度,还没有资格和别人拼天赋