trace-audit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseChrome DevTools Trace Audit
Chrome DevTools 性能追踪审计
Analyze a Chrome DevTools Performance trace and produce a comprehensive performance audit report.
分析Chrome DevTools性能追踪文件并生成全面的性能审计报告。
Usage
使用方法
/trace-audit <path-to-trace.json>The argument is the absolute path to a Chrome DevTools trace JSON file (exported from the Performance panel).
/trace-audit <path-to-trace.json>参数为从Performance面板导出的Chrome DevTools追踪JSON文件的绝对路径。
Workflow
工作流程
Follow these steps in order. Use parallel tool calls wherever noted.
按顺序执行以下步骤,注意在标注处使用并行工具调用。
Step 1 — Validate the trace file
步骤1 — 验证追踪文件
Read the first 100 lines of the file using the Read tool. Confirm it is a valid Chrome DevTools trace by checking for:
- A top-level array, or a bare JSON array starting with
traceEvents[ - Event objects with ,
name,cat,phfieldsts - Presence of or
__metadataeventsTracingStartedInBrowser
If validation fails, tell the user this doesn't appear to be a Chrome DevTools trace and stop.
使用Read工具读取文件的前100行。通过以下检查确认其为有效的Chrome DevTools追踪文件:
- 顶级的数组,或以
traceEvents开头的裸JSON数组[ - 包含、
name、cat、ph字段的事件对象ts - 存在或
__metadata事件TracingStartedInBrowser
如果验证失败,告知用户这似乎不是Chrome DevTools追踪文件并停止操作。
Step 2 — Extract metadata
步骤2 — 提取元数据
Use Grep on the trace file to extract (run these in parallel):
- Site URL — grep for or
TracingStartedInBrowserornavigationStartand look for a URL in theFrameCommittedInBrowserargs - Process names — grep for or
process_nameto identify renderer, browser, GPU processesthread_name - Trace time range — grep for the first and last values to compute trace duration
"ts":
使用Grep工具对追踪文件执行以下并行提取操作:
- 站点URL — 搜索、
TracingStartedInBrowser或navigationStart,并在FrameCommittedInBrowser字段中查找URLargs - 进程名称 — 搜索或
process_name以识别渲染进程、浏览器进程、GPU进程thread_name - 追踪时间范围 — 搜索第一个和最后一个值以计算追踪时长
"ts":
Step 3 — Run detection passes
步骤3 — 运行检测流程
Refer to for the full set of patterns and thresholds. Run all detection categories in parallel using Grep. For each category:
detection-heuristics.md- Use the specified grep pattern on the trace file
- Collect matching lines with surrounding context where helpful (or
-C 1)-C 2 - Count matches and extract durations/values from the matched JSON
The detection categories are:
- Long Tasks (with dur > 50000)
RunTask - Layout Thrashing (→
InvalidateLayoutpairs)Layout - Forced Reflows (events with
Layout)stackTrace - rAF Ticker Loops (frequency)
RequestAnimationFrame - Style Recalc Storms (with dur > 5000)
UpdateLayoutTree - Paint Storms (events with dur > 3000)
Paint - GC Pressure (/
MajorGC)V8.GC_MARK_COMPACTOR - CLS (cumulative score)
LayoutShift - INP (max duration)
EventTiming - Network Errors (with statusCode >= 400)
ResourceReceiveResponse - Redundant Fetches (same URL fetched multiple times)
- Script Eval (/
EvaluateScriptwith dur > 50000)CompileScript - Long Animation Frames (/
LoAF)LongAnimationFrame
参考中的完整模式和阈值。使用Grep工具并行运行所有检测分类。对于每个分类:
detection-heuristics.md- 对追踪文件使用指定的grep模式
- 收集匹配行及相关上下文(可使用或
-C 1参数)-C 2 - 统计匹配数量并从匹配的JSON中提取时长/数值
检测分类包括:
- Long Tasks(时长>50000的事件)
RunTask - Layout Thrashing(→
InvalidateLayout事件对)Layout - Forced Reflows(带有的
stackTrace事件)Layout - rAF Ticker Loops(触发频率)
RequestAnimationFrame - Style Recalc Storms(时长>5000的事件)
UpdateLayoutTree - Paint Storms(时长>3000的事件)
Paint - GC Pressure(/
MajorGC事件)V8.GC_MARK_COMPACTOR - CLS(累积分数)
LayoutShift - INP(最大时长)
EventTiming - Network Errors(状态码≥400的事件)
ResourceReceiveResponse - Redundant Fetches(同一URL被多次请求)
- Script Eval(时长>50000的/
EvaluateScript事件)CompileScript - Long Animation Frames(/
LoAF事件)LongAnimationFrame
Step 4 — Aggregate findings
步骤4 — 汇总检测结果
For each detection category:
- Compute total count of flagged events
- Extract the worst offender (max duration or highest score)
- Classify severity: Critical (red) or Warning (yellow) based on the thresholds in
detection-heuristics.md - Skip categories with zero findings
针对每个检测分类:
- 计算标记事件的总数
- 提取最严重的违规项(最长时长或最高分数)
- 根据中的阈值将严重性分类为Critical(严重)或Warning(警告)
detection-heuristics.md - 跳过无检测结果的分类
Step 5 — Identify timeline hotspots
步骤5 — 识别时间线热点
Group flagged events by timestamp into time windows (e.g., 500ms buckets). Identify windows where multiple issue categories overlap — these are hotspot ranges that represent the most problematic sections of the trace.
按时间戳将标记事件分组到时间窗口(如500ms桶)。识别存在多个问题分类重叠的窗口——这些是热点区间,代表追踪记录中问题最突出的部分。
Step 6 — Generate report
步骤6 — 生成报告
Output the report using the structure defined in . The report should be:
report-format.md- Actionable — every issue links to a concrete fix
- Scannable — use tables, severity badges, and clear headings
- Complete — cover all categories, even if just to say "no issues found"
使用中定义的结构输出报告。报告需满足:
report-format.md- 可执行性——每个问题都关联具体的修复方案
- 易读性——使用表格、严重性标识和清晰的标题
- 完整性——覆盖所有分类,即使仅说明“未发现问题”