【问题标题】:Using performance.mark() with Chrome dev tools performance tab将 performance.mark() 与 Chrome 开发工具性能选项卡一起使用
【发布时间】:2021-11-01 14:46:18
【问题描述】:

我希望看到我对 performance.mark(...) 的调用显示在 Chrome 的开发工具性能选项卡上。我可以在网上找到的所有文档似乎都指向不再存在的“时间轴”选项卡,而 the docs on the new Performance tab 对此没有什么要说的。

在我的代码中,我只是在做performance.mark('my mark name')。我也尝试对console.timeStamp('my mark name') 做同样的事情,因为我在一些旧文档中也看到了这一点。

如何在“性能”标签上看到这些对performance.mark() 的调用?

【问题讨论】:

    标签: javascript performance google-chrome


    【解决方案1】:

    在新的性能标签中,标记显示在“用户计时”中。 你需要使用

    performance.measure()

    标记标记的开始和结束 像这样:

    performance.mark('myMark-start');
    
    // your code 
    
    performance.mark('myMark-end');
    performance.measure('myPerfMarker', 'myMark-start', 'myMark-end');
    

    【讨论】:

    • 你是英雄 ^^ 应该被接受,因为网络上的文档太少了,谷歌弃用了时间戳文档页面并且没有提供指向新信息的链接......跨度>