小编给大家分享一下javascript如何利用perfORMance.timing进行性能分析,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!performance.timing:利用performance.timing进行
小编给大家分享一下javascript如何利用perfORMance.timing进行性能分析,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
performance.timing:利用performance.timing进行性能分析
window.onload = function() { setTimeout(function() { let t = performance.timing; console.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) + '%') } })}
看完了这篇文章,相信你对“JavaScript如何利用performance.timing进行性能分析”有了一定的了解,如果想了解更多相关知识,欢迎关注编程网精选频道,感谢各位的阅读!
--结束END--
本文标题: JavaScript如何利用performance.timing进行性能分析
本文链接: https://www.lsjlt.com/news/232511.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-21
2024-05-21
2024-05-21
2024-05-21
2024-05-21
2024-05-21
2024-05-21
2024-05-21
2024-05-21
2024-05-21
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0