Expand description
Hierarchical scoped profiler with RAII guards, frame reports, and flamegraph export. Hierarchical scoped profiler with RAII guards, frame reports, and flamegraph export.
§Types
ProfilerSession— manages one frame at a time; callbegin_frame(), open scopes withscope(), then finalise withend_frame().ScopeGuard— RAII guard returned byscope(); on drop it records the elapsed nanoseconds and pops the scope off the stack.ScopeNode— a node in the reconstructed profiling tree.FrameReport— the per-frame summary returned byend_frame(), containing the total wall-clock nanoseconds and the scope tree.
§Example
use oxiphysics::profiler::ProfilerSession;
let mut session = ProfilerSession::new();
session.begin_frame();
{
let _a = session.scope("physics");
{
let _b = session.scope("collision");
// inner work
} // _b drops here — records "collision"
} // _a drops here — records "physics"
let report = session.end_frame();
println!("frame ns: {}", report.frame_ns);
println!("csv:\n{}", report.to_csv());
println!("json:\n{}", report.to_json());
println!("folded:\n{}", report.to_folded_stacks());Structs§
- Frame
Report - A per-frame summary produced by
ProfilerSession::end_frame. - Profiler
Session - The profiler session. Manages one frame at a time.
- Scope
Guard - RAII scope guard returned by
ProfilerSession::scope. - Scope
Node - A node in the profiling tree, populated by
ProfilerSession::end_frame.