Benchmarking

Build Status Build status

This crate can be used to execute something and measure the execution time. It does not output anything to screens and filesystems.

Examples

```rust extern crate benchmarking;

fn main() { const VEC_LENGTH: usize = 100;

benchmarking::warm_up();

let bench_result = benchmarking::measure_function(|measurer| {
    let mut vec: Vec<usize> = Vec::with_capacity(VEC_LENGTH);

    measurer.measure(|| {
        for i in 0..VEC_LENGTH {
            vec.push(i);
        }
    });

    /*
        // Start the measurement
        for i in 0..VEC_LENGTH {
            vec.push(i);
        }
        // End the measurement
    */
}).unwrap();

println!("Filling 0 to 99 into a vec takes {:?}!", bench_result.elapsed());

} ```

```rust extern crate benchmarking;

fn main() { const VEC_LENGTH: usize = 100;

benchmarking::warm_up();

let bench_result = benchmarking::measure_function(|measurer| {
    let mut vec: Vec<usize> = Vec::with_capacity(VEC_LENGTH);

    measurer.measure_for_loop(0..VEC_LENGTH, |_, loop_seq| {
        vec.push(loop_seq);
    });

    /*
        for i in 0...VEC_LENGTH {
            // Start the measurement
            vec.push(i);
            // End the measurement
        }
    */
}).unwrap();

println!("Pushing a number into a vec takes {:?}!", bench_result.elapsed());

} ```

```rust extern crate benchmarking;

fn main() { const VEC_LENGTH: usize = 100;

benchmarking::warm_up();

let bench_result = benchmarking::measure_function(|measurer| {
    let mut vec: Vec<usize> = Vec::with_capacity(VEC_LENGTH);

    measurer.measure_while_loop(|loop_seq| {
        loop_seq < VEC_LENGTH
    }, |loop_seq| {
        vec.push(loop_seq);
    });

    /*
        let mut i = 0;

        while i < VEC_LENGTH {
            // Start the measurement
            vec.push(i);
            // End the measurement

            i += 1;
        }
    */
}).unwrap();

println!("Pushing a number into a vec takes {:?}!", bench_result.elapsed());

} ```

Crates.io

https://crates.io/crates/benchmarking

Documentation

https://docs.rs/benchmarking

License

MIT