Trait tango_bench::ErasedSampler
source · pub trait ErasedSampler {
// Required method
fn measure(&mut self, iterations: usize) -> u64;
// Provided method
fn estimate_iterations(&mut self, time_ms: u32) -> usize { ... }
}
Required Methods§
sourcefn measure(&mut self, iterations: usize) -> u64
fn measure(&mut self, iterations: usize) -> u64
Measures the performance if the function
Returns the cumulative execution time (all iterations) with nanoseconds precision,
but not necessarily accuracy. Usually this time is get by clock_gettime()
call or some other
platform-specific call.
This method should use the same arguments for measuring the test function unless prepare_state()
method is called. Only then new set of input arguments should be generated. It is NOT allowed
to call this method without first calling prepare_state()
.
Provided Methods§
sourcefn estimate_iterations(&mut self, time_ms: u32) -> usize
fn estimate_iterations(&mut self, time_ms: u32) -> usize
Estimates the number of iterations achievable within given time.
Time span is given in milliseconds (time_ms
). Estimate can be an approximation and it is important
for implementation to be fast (in the order of 10 ms).
If possible the same input arguments should be used when building the estimate.
If the single call of a function is longer than provided timespan the implementation should return 0.