新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
JavaScript如何利用performance.timing進(jìn)行性能分析
小編給大家分享一下JavaScript如何利用performance.timing進(jìn)行性能分析,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:空間域名、網(wǎng)絡(luò)空間、營銷軟件、網(wǎng)站建設(shè)、安岳網(wǎng)站維護(hù)、網(wǎng)站推廣。
performance.timing:利用performance.timing進(jìn)行性能分析
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('白屏?xí)r間 :' + (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內(nèi)存使用占比:' + (t.usedJSHeapSize / t.totalJSHeapSize * 100).toFixed(2) + '%') } }) }
看完了這篇文章,相信你對“JavaScript如何利用performance.timing進(jìn)行性能分析”有了一定的了解,如果想了解更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
名稱欄目:JavaScript如何利用performance.timing進(jìn)行性能分析
網(wǎng)站路徑:http://fisionsoft.com.cn/article/jgcohj.html