Simple (and very primitive) benchmarking macro.
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!(wrapperfunc, numberof_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
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn bench_ok() {
bench!(wrapper, "Var1");
bench!(wrapper, 100_000, "Var2");
}
fn wrapper() {
for i in 0..1000 {
let _ = i*i;
}
}
}