JS - 利用performance.timing进行性能分析
发布日期:2021-10-02 12:55:45
浏览次数:21
分类:技术文章
本文共 839 字,大约阅读时间需要 2 分钟。
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) + '%') } })}
转载地址:https://blog.csdn.net/Jie_1997/article/details/112238199 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
初次前来,多多关照!
[***.217.46.12]2024年04月09日 03时10分50秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
AcWing - 最长连续不重复子序列(双指针)
2019-04-28
AcWing - 数组元素的目标和(双指针)
2019-04-28
AcWing - 区间和(离散化&前缀和)
2019-04-28
AcWing - 区间合并(贪心)
2019-04-28
AcWing - 单链表(模拟)
2019-04-28
AcWing - 双链表(模拟)
2019-04-28
AcWing - KMP字符串(KMP)
2019-04-28
来一个总结吧
2019-04-28
有趣的句子
2019-04-28
每天一道 python 面试题 - Python中的元类(metaclass) 详细版本
2019-04-28
Scrapy(6)Item loader 加载器详解
2019-04-28
每日一道python面试题 - Python的实例,类和静态方法揭秘
2019-04-28
今日金融词汇---新股新债前面的N,是什么?
2019-04-28
每日一道python面试题 - Python的实例,类和静态方法揭秘
2019-04-28
原创专辑来了
2019-04-28
好好做好你喜欢做的事情,并且把它做好
2019-04-28
反馈不足
2019-04-28
人生永远没有太晚的开始
2019-04-28
python 周日福利来了
2019-04-28
状态模式
2019-04-28