pub trait MeasureTarget {
    // Required methods
    fn measure(&mut self, iterations: usize) -> u64;
    fn estimate_iterations(&mut self, time_ms: u32) -> usize;
    fn next_haystack(&mut self) -> bool;
    fn sync(&mut self, seed: u64);
    fn name(&self) -> &str;
}

Required Methods§

source

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 system call.

This method should use the same arguments for measuring the test function unless next_haystack() method is called. Only then new set of input arguments should be generated. Although it is allowed to call this method without first calling next_haystack(). In which case first haystack should be generated automatically.

source

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.

source

fn next_haystack(&mut self) -> bool

Generates next haystack for the measurement

Calling this method should update internal haystack used for measurement. Returns true if update happend, false if implementation doesn’t support haystack generation. Haystack/Needle distinction is described in Generator trait.

source

fn sync(&mut self, seed: u64)

Synchronize RNG state

If this implementation has linked generator with RNG state, this method should delegate to Generator::sync()

source

fn name(&self) -> &str

Name of the benchmark

Implementors§

source§

impl<F, O, G> MeasureTarget for GenFunc<F, G>
where G: Generator, F: Fn(&G::Haystack, &G::Needle) -> O,