rprofile

Crates.iorprofile
lib.rsrprofile
version0.1.3
sourcesrc
created_at2024-08-20 19:23:18.534483
updated_at2024-08-21 16:31:31.140783
descriptionA simple crate to measure processor timings in selected samples of execution
homepage
repository
max_upload_size
id1345718
size4,470
Diane M (princess-entrapta)

documentation

README

The crate allow to trace sample execution, in-between start and stop trace, and extract statistics of the functions consuming the most resources.

Example usage

fn k() {
    trace_cpu!("k", for _i in 0..1000 {})
}

fn f() {
    for i in 0..100 {
        trace_cpu!("g", g());
    }
    for j in 0..10000 {}
}

fn g() {
    for i in 0..100 {
        k()
    }
}
fn main() {
    start();
    trace_cpu!("f1", f());
    trace_cpu!("f2", f());
    stop();
    f();
    show();
}

Will output:

f2                            : 1          calls | 43.356     total ms -- Timing overhead 10.1       ms
k                             : 20000      calls | 58.118     total ms -- Timing overhead 0          ms
f1                            : 1          calls | 40.9       total ms -- Timing overhead 10.1       ms
g                             : 200        calls | 83.916     total ms -- Timing overhead 20         ms

The overhead timing are indicative of the amount spend in the timing macros.

Commit count: 0

cargo fmt