exec_duration
Get execution duration of a function or a bloc of code
Stupid and easy to use Rust code instrumentalization library.
This module provides a simple API to measure the execution duration of a function or a block code.
Install
[dependencies]
exec_duration = "0.1.1"
Examples
use exec_duration::ExecProbe;
fn function_1() {
let mut ep = ExecProbe::new("function_1");
ep.add_point("part 1");
ep.add_point("part 2");
ep.add_point("part 3");
}
fn function_2() {
let mut ep = ExecProbe::new("function_2");
ep.add_point("part 1");
ep.add_point("part 2");
ep.stop();
}
fn main() {
function_1();
function_2();
if let Ok(list) = exec_duration::fetch_results() {
for r in list.iter() {
println!("{}", r);
}
}
}