Crate partial_callgrind

Source
Expand description

Easy to use client requests to start/stop callgrind at specific location of your code for precise profiling (100% Rust).

For now only x86_64 is supported.

§Examples

Skip Vec initialization code and profile only sort. Compile in release mode and then use valgrind --tool=callgrind --collect-atstart=no --instr-atstart=no {exec}.

use partial_callgrind::{start, stop};
use rand::Rng;

fn main() {
    let mut rng = rand::thread_rng();

    let mut data: Vec<u8> = (0..10_000).into_iter().map(|_| rng.gen::<u8>()).collect();
    start();
    data.sort();
    stop();
}

Functions§

start
Start instrumentation and toggle collection state. With --collect-atstart=no option, callgrind’s collection state is disabled at the beginning.
start_instrumentation
stop
Toggle collection state and stop instrumentation.
stop_instrumentation
toggle_collection