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 profilingOr customize the CPU sampling frequency:
ⓘ
rsprof_trace::profiler!(cpu = 199); // CPU at 199Hz + heap profilingBuild with frame pointers for accurate stack traces:
RUSTFLAGS="-C force-frame-pointers=yes" cargo build --release --features profilingWhen 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§
- Profiling
Allocator - A profiling allocator that wraps the system allocator.