#timing #execution #measure #sample #processor #statistics #resources

rprofile

A simple crate to measure processor timings in selected samples of execution

4 releases

0.1.3 Aug 21, 2024
0.1.2 Aug 20, 2024
0.1.1 Aug 20, 2024
0.1.0 Aug 20, 2024

#178 in Profiling

Download history 283/week @ 2024-08-17 23/week @ 2024-08-24 18/week @ 2024-09-14 36/week @ 2024-09-28 1/week @ 2024-10-05

101 downloads per month

MIT license

5KB
58 lines

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.

Dependencies

~1.2–6MB
~24K SLoC