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"] }For CPU profiling only:
ⓘ
fn main() {
// Start CPU profiling at 99Hz
rsprof_trace::start_cpu_profiling(99);
// Your application code...
// Stop profiling (optional, stops on process exit)
rsprof_trace::stop_cpu_profiling();
}For heap profiling, use the global allocator:
ⓘ
#[global_allocator]
static ALLOC: rsprof_trace::ProfilingAllocator = rsprof_trace::ProfilingAllocator;Build with frame pointers for accurate stack traces:
RUSTFLAGS="-C force-frame-pointers=yes" cargo build --release --features profilingStructs§
- Profiling
Allocator - A profiling allocator that wraps the system allocator.