Crate statslicer

Source
Expand description

§statslicer

Statslicer is a platform for running experiments and collecting their results.

use guacamole::combinators::*;
use guacamole::Guacamole;

use statslicer::{benchmark, black_box, statslicer_main, Bencher, Parameter, Parameters};

#[derive(Debug, Default, Eq, PartialEq)]
struct MyParameters {
    elements: usize,
}

impl Parameters for MyParameters {
    fn params(&self) -> Vec<(&'static str, Parameter)> {
        vec![
            ("elements", Parameter::Integer(self.elements as u64)),
        ]
    }
}

fn bench_sort(params: &MyParameters, b: &mut Bencher) {
    let mut guac = Guacamole::new(b.seed());
    let array = to_vec(constant(params.elements), any::<u64>)(&mut guac);
    let bin_searches = to_vec(constant(b.size()), any::<u64>)(&mut guac);
    b.run(|| {
        for needle in bin_searches.iter() {
            let _ = black_box(array.binary_search(needle));
        }
    });
}

benchmark! {
    name = my_sort_benchmark;
    MyParameters {
        elements in [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],
    }
    bench_sort
}

statslicer_main! { my_sort_benchmark }

§Status

Experimental. Likely to change in the near future.

§Scope

This library provides the statslicer benchmark tools and a binary to derive data and colate histograms.

§Warts

§Documentation

The latest documentation is always available at docs.rs.

Macros§

benchmark
A macro for defining a benchmark sweep.
statslicer_main
The macro for creating main functions.

Structs§

Bencher
BenchmarkOptions
Options for the benchmark.
Cycle
Moments
Moments are the statistical moments of mean (m1), standard deviation (m2), skewness (m3) and kurtosis (m4). When a distribution goes long tailed, skewness and kurtosis blow up, so the hope is that this type will be good for monitoring general “no bad tail” insights.
UnboundParameters
Unbound parameters convers from a string like foo,bar,baz,quux.
UntypedParameters
Untyped parameters converts from a string like foo=1,bar=3.14,baz=true,quux. The input is untyped, and the result is free-form, as opposed to a type like what implements Parameters.

Enums§

Parameter
Parameter binds a typed value to an experiment.
Type
Type captures the type of a Parameter.

Traits§

Parameters
Parameters provides the parameters for an experiment/benchmark.

Functions§

benchmark
A stub used to run the benchmarks, so that profilers can zero counters on entry and count them on exit.
benchmark_main
black_box
Try to prevent the compiler from eliminating code.
compute_difference
experiment_and_parameters
increment_indices
summarize