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:
[]
= { = "0.1", = ["profiling"] }
Enable profiling with the profiler! macro:
profiler!; // CPU at 99Hz + heap profiling
Or customize the CPU sampling frequency:
profiler!; // CPU at 199Hz + heap profiling
Build with frame pointers for accurate stack traces:
RUSTFLAGS="-C force-frame-pointers=yes"
When the profiling feature is disabled, the macro expands to a no-op
allocator passthrough with zero overhead.