第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > js performance.timing:利用performance.timing进行性能分析

js performance.timing:利用performance.timing进行性能分析

时间:2022-02-21 18:46:22

相关推荐

js performance.timing:利用performance.timing进行性能分析

window.onload = function(){setTimeout(function(){let t = performance.timingconsole.log('DNS查询耗时 :' + (t.domainLookupEnd - t.domainLookupStart).toFixed(0))console.log('TCP链接耗时 :' + (t.connectEnd - t.connectStart).toFixed(0))console.log('request请求耗时 :' + (t.responseEnd - t.responseStart).toFixed(0))console.log('解析dom树耗时 :' + (t.domComplete - t.domInteractive).toFixed(0))console.log('白屏时间 :' + (t.responseStart - t.navigationStart).toFixed(0))console.log('domready时间 :' + (t.domContentLoadedEventEnd - t.navigationStart).toFixed(0))console.log('onload时间 :' + (t.loadEventEnd - t.navigationStart).toFixed(0))if(t = performance.memory){console.log('js内存使用占比 :' + (t.usedJSHeapSize / t.totalJSHeapSize * 100).toFixed(2) + '%')}})}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。