Crate rsprof_trace

Crate rsprof_trace 

Source
Expand description

Self-instrumentation library for rsprof.

This crate provides CPU and heap profiling through self-instrumentation:

  • CPU profiling: Timer-based sampling using SIGPROF
  • Heap profiling: Custom allocator that tracks allocations

§Usage

Add to your Cargo.toml:

[dependencies]
rsprof-trace = { version = "0.1", features = ["profiling"] }

Enable profiling with the profiler! macro:

rsprof_trace::profiler!();  // CPU at 99Hz + heap profiling

Or customize the CPU sampling frequency:

rsprof_trace::profiler!(cpu = 199);  // CPU at 199Hz + heap profiling

Build with frame pointers for accurate stack traces:

RUSTFLAGS="-C force-frame-pointers=yes" cargo build --release --features profiling

When the profiling feature is disabled, the macro expands to a no-op allocator passthrough with zero overhead.

Macros§

profiler
No-op when heap feature is disabled (CPU-only not supported with this macro)

Structs§

ProfilingAllocator
A profiling allocator that wraps the system allocator.

Functions§

start_cpu_profiling
stop_cpu_profiling

Type Aliases§

HeapProfiler