GithubHelp home page GithubHelp logo

window.performance 详解 about blog HOT 30 OPEN

fredshare avatar fredshare commented on August 17, 2024 5
window.performance 详解

from blog.

Comments (30)

ywang1724 avatar ywang1724 commented on August 17, 2024 6

关于其中几项值的计算方法有些疑问,麻烦楼主解答
1、request请求耗时 :responseEnd - responseStart
是否应该为responseEnd - requestStart?
2、白屏时间 :responseStart - navigationStart
responseStart 是开始接收响应的时间,白屏时间是指页面开始出现内容的时间,这两个时间是否是一样的?

from blog.

hehongwei44 avatar hehongwei44 commented on August 17, 2024

相当不错

from blog.

fredshare avatar fredshare commented on August 17, 2024

@hehongwei44 多谢支持~~

from blog.

hehongwei44 avatar hehongwei44 commented on August 17, 2024

用在实际项目中了嘛 稳定性怎么样

from blog.

fredshare avatar fredshare commented on August 17, 2024

@hehongwei44 实际测速就是用performance接口的,移动端支持度在40~60%左右。

from blog.

hehongwei44 avatar hehongwei44 commented on August 17, 2024

我也是用performance对像来上报的,不过没有你封装的优雅

from blog.

hehongwei44 avatar hehongwei44 commented on August 17, 2024

还请教你一个问题,不支持performance对象的浏览器 怎么做上报的。腾讯是怎么做的呢?@fredshare

from blog.

fredshare avatar fredshare commented on August 17, 2024

不支持performance的情况下,我们做了domready、onload、白屏时间等的统计,通过埋点的方式进行计算统计,比如domready,head最前面埋一个点,html尾部卖一个点,两个之间的差值大约等于domready时间;onload就是用DOMContentLoaded触发的时候打点等。
我记得还有多普勒测速,这个是在performance标准出来之前很多公司有使用到的方案。

from blog.

hehongwei44 avatar hehongwei44 commented on August 17, 2024

有写地方没太明白,setTimingRpt中的f1,f2,f3_ie,f3_c 具体指的是什么?我只是把_da上传服务器接口,你的那些参数是不是对我作用不大?

from blog.

hehongwei44 avatar hehongwei44 commented on August 17, 2024

还有个问题就是,你的_da参数得到的值都是与navigationStart的差值,比如我要得到“解析dom树耗时”,但是_da没有提供,你们是不是后台对其进行了处理。

from blog.

fredshare avatar fredshare commented on August 17, 2024

image
哦,这个涉及到上报系统的数据结构定义,可能一个业务下有多个站点,每个站点下有不少页面,需要针对每一个业务、站点、页面分别申请不一样的id来区别

from blog.

fredshare avatar fredshare commented on August 17, 2024

@hehongwei44 这个demo中的函数是一个标准的上报performance接口的函数
如果需要上报比如dom树解析耗时,你需要前端算出dom树解析,然后上报。计算方法:
image

from blog.

hehongwei44 avatar hehongwei44 commented on August 17, 2024

哦 我了解了,不过你上传页面的URL应该也可以做到区分是哪个页面的上报吧,只是你们自己对齐封装了吧。

from blog.

fredshare avatar fredshare commented on August 17, 2024

@hehongwei44 是的,前端封装好了,后台来区分比较麻烦,需要维护一大堆map对应表

from blog.

hehongwei44 avatar hehongwei44 commented on August 17, 2024

哦 我了解了,因为你我的业务场景不一样,你的函数看样子,我不能直接拿上就用。自己还得在你的代码上做一层封装。

from blog.

hehongwei44 avatar hehongwei44 commented on August 17, 2024

if (!_t.domContentLoadedEventStart) {
_ta.splice(15, 2, 'domContentLoaded', 'domContentLoaded');
} else {
if (f3_c) {
f3 = f3_c;
}
}
你这段代码的意图是什么?

from blog.

fredshare avatar fredshare commented on August 17, 2024

@hehongwei44
image

from blog.

hehongwei44 avatar hehongwei44 commented on August 17, 2024

能说说异常出现的原因嘛

from blog.

fredshare avatar fredshare commented on August 17, 2024

@hehongwei44 你可以看看这个http://www.cnblogs.com/_franky/archive/2011/11/07/2238980.html 上面有详细的解释

from blog.

zlzdp avatar zlzdp commented on August 17, 2024

mark

from blog.

chua1989 avatar chua1989 commented on August 17, 2024

@ywang1724 所以说白屏时间计算的不对,白屏时间=开始渲染时间(首字节时间+HTML下载完成时间)+头部资源加载时间;对应的应该是白屏时间=domLoading - navigationStart +头部资源加载时间;头部资源加载时间还是要自己算

from blog.

zhujun24 avatar zhujun24 commented on August 17, 2024

loadEventEnd:文档触发 load事件结束后 的时间。如果load事件没有触发,那么该接口就返回0。所以在onload 里计算这个是不是会出问题?

from blog.

hellozhangran avatar hellozhangran commented on August 17, 2024

request请求耗时 :responseEnd - responseStart
这一条我不太理解,尤其是responseEnd这个时间点。
responseEnd指的是服务器返回最后一个字节的时间!那这最后一个字节指的是什么呢?
如果请求一个html页面,那最后一个字节指的是html页面返回完毕?还是里面的js、css返回完毕。。。如果是的话,responseEnd - responseStart 应该是下载时间了吧,怎么只是请求时间呢??

from blog.

zqs-zjj-1208 avatar zqs-zjj-1208 commented on August 17, 2024

大神 ,你好。敢问如何测试监控移动端设备呢?没写过js,不知道怎么弄,望百忙之中指点一二,多谢!!!

from blog.

reaperme avatar reaperme commented on August 17, 2024

你这里的白屏时间计算是错误的,没有包括头部资源加载的时间

from blog.

fredshare avatar fredshare commented on August 17, 2024

@reaperme ,在responseStart开始的时候,页面就开始渲染了。

from blog.

fredshare avatar fredshare commented on August 17, 2024

@zqs-zjj-1208 移动端监控是一样的,移动端也有performance接口

from blog.

fredshare avatar fredshare commented on August 17, 2024

@hellozhangran 这里的请求耗时指的是从发起请求到请求结束的时间

from blog.

junbinxu avatar junbinxu commented on August 17, 2024

您好,请问怎么获取每个资源的waiting time ?

from blog.

moozeeli avatar moozeeli commented on August 17, 2024

图片看不到了,是我网络的问题吗?

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.