Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【性能记录】浏览器中获取微秒 #118

Open
Genluo opened this issue Jun 13, 2023 · 0 comments
Open

【性能记录】浏览器中获取微秒 #118

Genluo opened this issue Jun 13, 2023 · 0 comments
Assignees

Comments

@Genluo
Copy link
Owner

Genluo commented Jun 13, 2023

在浏览器中有一个 performance.now() 的接口,它表达了从页面加载到执行该语句之间的时间间隔,是一个衡量值。页面加载结束时间通过 performance.timing.navigationStart 获取,两个值相加,就可以得到执行 performance.now() 的具体值,该值比 Date.now() 精度要高。

和 JavaScript 中其他可用的时间类函数(比如Date.now)不同的是,window.performance.now()返回的时间戳没有被限制在一毫秒的精确度内,相反,它们以浮点数的形式表示时间,精度最高可达微秒级。

https://developer.mozilla.org/zh-CN/docs/Web/API/Performance/now

@Genluo Genluo self-assigned this Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant