javascript - 持续时间为负的 PerformanceObserver 标记 api
问题描述
我正在尝试准确marks
了解我的 React 代码的某些 JS api 的执行时间。我在规格中看到了这个
Set entry's duration attribute to the duration from start time to end time.
The resulting duration value MAY be negative.
我很好奇为什么其中一些durations
是负面的。也就是说,我开始mark
in 代码,并mark
在一定以后的时间结束。我的全部目的是捕捉持续时间,所以我对结果有点困惑。
const k = 'EXAMPLE_KEY';
const start = `start:${k}`;
const end = `end:${k}`;
//// Parent React Component
performance.mark(start);
/// Child Component, which happens to be an img
const onLoad = () => {
performance.mark(end);
const result = performance.measure(k, start, stop);
/// Yields negative duration
}
当 aduration
为负时,有哪些注意事项?
这是一个非常相似的 SO 问题,但该问题没有答案,也没有手动处理start/stop
。任何帮助表示赞赏!
解决方案
推荐阅读
- php - 使用 PHP #2 通过 SSL 将 AWS EC2 实例连接到 RDS MySQL
- java - 运行 Java 代码时出现一些错误
- python - 如何使用sql查询获取表中存在的所有行,其中年份是闰年
- mongodb - 直到昨天才使用 python / pymongo 将 JSON 数据插入 MongoDB
- selenium - Selenium 点击功能键
- prolog - 查找连接时给出给定列表的所有子列表列表
- python - Pycharm文件读取程序在调试模式下工作但在发布模式下失败?
- python - 使用 strptime 的日期转换跳过 UTC 部分
- python - 如何在networkx中使用python随机排列图的节点?
- javascript - 有什么方法可以在 reactjs 的 Link 标签中使用 target="_blank"