Skip to main content

Module profile

Module profile 

Source
Expand description

阶段 B3:Frame Profile — CPU paint 耗时采样

目标:每帧记录 CPU 端 paint(layout + collect paint list + GPU submit)耗时, 每秒聚合输出 avg/min/max/p50/p99/fps 到 env_logger,辅助性能调优。

设计:

  • 1024-slot ring buffer(每帧覆盖,内存 ~4KB)
  • record(paint_us) 写入;maybe_report() 每秒触发,返回 FrameReport
  • 简洁版:不依赖 wgpu-profiler/puffin,纯 std::time + log

不依赖 GPU 端 timer(那要 timestamp query / wgpu-profiler,复杂)。 这里只测 CPU 侧:从 render_frame() 开始到 queue.submit() 结束。

§后续扩展(MVP 后)

  • 拆 CPU 端:layout_us / collect_paint_us / submit_us 三段
  • GPU 端:wgpu timestamp query(wgpu 30 支持,但要 enable feature)
  • GUI overlay:左上角显示 fps(用 TextWidget)

Structs§

FrameProfile
阶段 B3:FrameProfile — 每秒聚合 CPU paint 耗时
FrameReport
阶段 B3:聚合报告(每秒输出一次)