首页 > 解决方案 > Chrome 开发工具跟踪文件的完整事件中“dur”的总和

问题描述

我有来自 chrome 开发工具的跟踪文件,用于我的 Web 应用程序的特定工作流程。我试图弄清楚工作流程所花费的总时间。

我正在使用 Puppeteer 脚本和它的跟踪功能来执行此操作。我通读了跟踪文件 JSON,按阶段类型过滤 - 'X' 是完整事件。过滤后,我总结了所有“dur”字段,我相信这应该给我工作流程的总时间。

结果却大相径庭。总持续时间太大了,甚至无法考虑远程接近我在屏幕上可以看到的内容。

假设这个时间是毫秒微秒(在 JSON 的任何地方都没有提到它,除了在本文末尾链接的文档中)

我还需要过滤任何其他字段吗?(可能重复?

// filter out only complete events
const allCompleteEvents = parsedJSON.filter(e => e.ph === 'X')
                          .map(completeEvent => {
                              const {pid, tid, dur, name} = completeEvent;
                              return { pid, tid, dur, name}
                        });

// sum of durations...this number is way too big to be correct! 
const completeEventsDuration = completeEvents.reduce((total, curr) => total + curr.dur, 0);   

参考:https ://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#

标签: google-chromegoogle-chrome-devtoolschromiumpuppeteerchrome-devtools-protocol

解决方案


推荐阅读