gpt4 book ai didi

javascript - 具有多个同名标记的性能测量

转载 作者:行者123 更新时间:2023-12-05 07:11:25 30 4
gpt4 key购买 nike

我目前正在通过运行 window.performance.mark('transition-start') 在每个页面转换上设置自定义标记。之后,当页面的首屏部分处于交互状态时,我创建了另一个标记,window.performance.mark('transition-end')。当用户在这个单页应用程序中执行多个页面转换时,会出现'transition-start'和'transition-end'的多个标记。

当使用 window.performance.measure('transition', 'transition-start', transition-end') 时,考虑到多个标记,我能否确保始终使用最新的标记是否存在同名?我已经在 Firefox 和 Chrome 中对此进行了测试,并查看了使用的最新标记,但我找不到有关此用例的文档。

最佳答案

在 User Timing API 规范中有说明:

if mark is a DOMString, let end time be the value of the startTime attributefrom the most recent occurrence of a PerformanceMark object in theperformance entry buffer whose name is mark. If no matching entry isfound, throw a SyntaxError.

在计算持续时间时间戳时,Measure 会考虑Most Recent 标记。

详细信息可以在以下文档中阅读:

关于javascript - 具有多个同名标记的性能测量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60778775/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com