/// Given a function to profile, profiles it multiple times such that it runs at least min_time
/// seconds, returning the average time and the number of runs. Does not yet handle failures.
Given a function to profile, profiles it multiple times such that it runs at least min_time
seconds, returning the average time and the number of runs. Does not yet handle failures.
Given a function to profile profiles it multiple times such that it runs at least min_time seconds returning the average time and the number of runs . Does not yet handle failures .
pub fn profile_longer_than<F>(mut f: F, min_time: f64, min_runs: u64) -> (f64, u64)
where
    F: FnMut(),
{
    let start = get_user_thread_cpu_time_seconds();
    let mut now = start;
    let mut iteration = 0;
    while (now - start) < min_time || iteration < min_runs {
        f();
        now = get_user_thread_cpu_time_seconds();
        iteration += 1;
    }
    return (
        (now - start) / (if iteration == 0 { 1. } else { iteration as f64 }),
        iteration,
    );
}
pub fn profile_longer_than < F > ( mut f : F , min_time : f64 , min_runs : u64 ) -> ( f64 , u64 ) where F : FnMut ( ) , { let start = get_user_thread_cpu_time_seconds ( ) ; let mut now = start ; let mut iteration = 0 ; while ( now - start ) < min_time || iteration < min_runs { f ( ) ; now = get_user_thread_cpu_time_seconds ( ) ; iteration += 1 ; } return ( ( now - start ) / ( if iteration == 0 { 1. } else { iteration as f64 } ) , iteration , ) ; }
Given a function to profile, profiles it multiple times such that it runs at least min_time
seconds, returning the average time and the number of runs.
Given a function to profile profiles it multiple times such that it runs at least min_time seconds returning the average time and the number of runs .
f
F
min_time
f64
min_runs
u64