4 releases

✓ Uses Rust 2018 edition

new 0.1.4 May 23, 2020
0.1.3 May 23, 2020
0.1.2 May 23, 2020
0.1.1 May 23, 2020
0.1.0 May 22, 2020

#40 in Profiling

MIT license

3KB

mybench

Crates.io

Simple (and very primitive) benchmarking macro.

Use cases:

  • bench!(wrapper_func, "prompt") Сalculates average execution time for code inside wrapper_func function for 10,000 repetitions. The result is displayed as prompt: xxx.yy ms

  • bench!(wrapper_func, number_of_repetitions, "prompt") Сalculates average execution time for code inside wrapper_func function for number_of_repetitions repetitions. The result is displayed as prompt: xxx.yy ms

Examples


extern crate mybench;

use mybench::bench;

#[test]
fn bench_ok() {
    bench!(wrapper, "Var1");
    bench!(wrapper, 100_000, "Var2");
}

fn wrapper() {
    for i in 0..1000 {
        let _ = i*i;
    }
}

No runtime deps