#[macro_export] macro_rules! phoenix_function_timer {
($function_timer:ident, $nb_element:expr, $func_call_bench:expr) => {
use std::time::Instant;
use std::cmp::Ordering;
{
let function_name: String = String::from(*String::from(stringify!($func_call_bench)).split("(").collect::<Vec<_>>().first().unwrap());
$function_timer.set_function_name(&function_name);
let mut vec_time_ns: Vec<f64> = vec![];
for _ in 0..$function_timer.get_nb_measure() {
let begin_time_ns = Instant::now();
for _ in 0..$function_timer.get_nb_call_per_measure() {
$func_call_bench;
}
let ellapsed_time_ns: f64 = (begin_time_ns.elapsed().as_nanos()/($function_timer.get_nb_call_per_measure() as u128) ) as f64;
vec_time_ns.push(ellapsed_time_ns);
}
vec_time_ns.sort_by(|a, b| if a < b {
Ordering::Less
}else if a == b {
Ordering::Equal
}else{
Ordering::Greater
}
); $function_timer.add_time_perf(&PEllapsedTime::new(
$nb_element,
vec_time_ns[0],
*vec_time_ns.last().unwrap(),
vec_time_ns[vec_time_ns.iter().count()/2],
vec_time_ns[vec_time_ns.iter().count()/4],
vec_time_ns[(3*vec_time_ns.iter().count())/4],
));
};
};
}