Benchmarking

CI

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

Examples

```rust const VEC_LENGTH: usize = 100;

benchmarking::warm_up();

let benchresult = benchmarking::measurefunction(|measurer| { let mut vec: Vec = Vec::withcapacity(VECLENGTH);

unsafe {
    vec.set_len(VEC_LENGTH);
}

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

vec

}).unwrap();

println!("Reading a number from a vec takes {:?}!", bench_result.elapsed()); ```

```rust const VEC_LENGTH: usize = 100;

benchmarking::warm_up();

let benchresult = benchmarking::measurefunction(|measurer| { let mut vec: Vec = Vec::withcapacity(VECLENGTH);

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

vec

}).unwrap();

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

```rust const VEC_LENGTH: usize = 100;

benchmarking::warm_up();

let benchresult = benchmarking::measurefunction(|measurer| { let mut vec: Vec = Vec::withcapacity(VECLENGTH);

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

vec

}).unwrap();

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

```rust const VEC_LENGTH: usize = 100;

benchmarking::warm_up();

let benchresult = benchmarking::measurefunctionn(2, |measurers| { let mut vec: Vec = Vec::withcapacity(VEC_LENGTH);

for i in 0..VEC_LENGTH {
    measurers[1].measure(|| {
        vec.push(i);
    });
}

for i in 0..VEC_LENGTH {
    measurers[0].measure(|| {
        vec[i]
    });
}

vec

}).unwrap();

println!("Reading a number from a vec takes {:?}!", benchresult[0].elapsed()); println!("Pushing a number into a vec takes {:?}!", benchresult[1].elapsed()); ```

Crates.io

https://crates.io/crates/benchmarking

Documentation

https://docs.rs/benchmarking

License

MIT