Skip to main content

Module profiler

Module profiler 

Source
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; call begin_frame(), open scopes with scope(), then finalise with end_frame().
  • ScopeGuard — RAII guard returned by scope(); 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 by end_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§

FrameReport
A per-frame summary produced by ProfilerSession::end_frame.
ProfilerSession
The profiler session. Manages one frame at a time.
ScopeGuard
RAII scope guard returned by ProfilerSession::scope.
ScopeNode
A node in the profiling tree, populated by ProfilerSession::end_frame.