#profiler #no-std #no-alloc

no-std peach_profiler

A performant, low-overhead instrumentation-based profiler. Just peachy.

21 releases

Uses new Rust 2024

new 0.3.0 Nov 13, 2025
0.2.4 Oct 16, 2025
0.1.14 Oct 2, 2025
0.1.13 Sep 28, 2025

#133 in Profiling

Download history 296/week @ 2025-09-18 849/week @ 2025-09-25 283/week @ 2025-10-02 393/week @ 2025-10-09 270/week @ 2025-10-16 5/week @ 2025-10-23

672 downloads per month

MIT/Apache

26KB
320 lines

Peach Profiler 🍑 is a performant, low-overhead profiler. It's just peachy.


Peach Profiler in action

use peach_profiler::{time_block, time_main, time_function};

// Add the `time_main` macro to the main function
#[time_main]
fn main() {
    let answer = {
        // Time a block
        time_block!("answer_block");

        fibonacci(22)
    };

    println!("{answer}");
}

// Time a function
#[time_function]
fn fibonacci(x: usize) -> usize {
    if x == 0 || x == 1 {
        return 1;
    }

    fibonacci(x - 1) + fibonacci(x - 2)
}

---------- Outputs ----------

28657

______________________________________________________
Total time: 1.7490ms (CPU freq 4300860492)
        answer_block[1]: 6665, (0.09%, 99.63% w/children)
        fibonacci[57313]: 7487891, (99.54%)

To Use

The Peach Profiler will only add the instrumentation needed to profile and output performance metrics if the profile feature is enabled. Without it just the Total time will be shown if main is marked with #[time_main].

Either add the profile feature with the dependancy in the Cargo.toml file, i.e.:

[dependencies]
peach_profiler = { version = "0.2", features = ["profile"]}

to always profile your code.

Or add a feature to your crate in the Cargo.toml file, i.e.:

[features]
profile = ["peach_profiler/profile"]

And then instrumentation will only be added when your program is run with the feature specified, i.e. cargo r --features=profile

Run in a no_std env by disabling default features:

[dependencies]
peach_profiler = { version = "0.2", default_features = false }

Debugging

If you are missing a timed function or block from the output there could be the potential for hash collisions that aren't checked for in the default execution. Running Peach Profiler with the debug feature will panic with collision information if one is found.

Dependencies

~0.2–2.2MB
~44K SLoC