rustyphoenixmicrobenchmark 1.3.0

Toolset for function micro-benchmarking. Rust equivalent of C++ [PhoenixMicroBenchmark](https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/test-benchmark/PhoenixMicroBenchmark)
Documentation
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/

///A macro to call properly the evaluation function for you
/// # Parameters
/// - `function_timer` : PFunctionTimer to be used to measure performances of the given func_call_bench
/// - `nb_element` : number of elements processed
/// - `func_call_bench` : function to be benchmarked
/// # Errors
/// Panic if nb_test_perf == 0
#[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() {
				//We have to check if it is really nanoseconds
				// let begin_time_ns: i64 = chrono::offset::Local::now().timestamp() as i64;
				let begin_time_ns = Instant::now();
				for _ in 0..$function_timer.get_nb_call_per_measure() {
					$func_call_bench;
				}
				// let ellapsed_time_ns: f64 = (((chrono::offset::Local::now().timestamp() as i64) - begin_time_ns) as f64)/(nb_call_per_test as f64);
				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);
			}
			//The horrible ordering of a vector of f64
			vec_time_ns.sort_by(|a, b| if a < b {
					Ordering::Less
				}else if a == b {
					Ordering::Equal
				}else{
					Ordering::Greater
				}
			);	//Let's sort the vector of ellapsed times in nanoseconds
			// println!("micro_benchmark_ns : vec_time_ns : {:?}", vec_time_ns);
			$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],
			));
		};
	};
}