Struct pew::State [] [src]

pub struct State<T> { /* fields omitted */ }

The benchmark state

At a high level, it allows one to pause/resume the timer and also access an argument for this run of the benchmark.

T will either be u64 in the case a generator is not specified, or a user defined `T: Clone

  • Defaultif a generator(s) is defined (whereT` is the return type of the final specified generator).

Methods

impl<T> State<T>
[src]

[src]

[src]

Pauses the benchmark timer. Useful to do any initialization work, etc. The state begins in a running (unpaused) state.

Examples

use pew::{self, State};
use std::vec::Vec;

fn bm_simple(state: &mut State<u64>) {
    state.pause();
    let mut vec = Vec::new();
    vec.push(1);
    state.resume();
    pew::do_not_optimize(vec.get(1));
}

Panics

Panics if the state is already paused.

[src]

Resumes the benchmark timer. Useful after any initialization work, etc. The state begins in a running (unpaused) state.

#Examples

use pew::{self, State};
use std::vec::Vec;

fn bm_simple(state: &mut State<u64>) {
    state.pause();
    let mut vec = Vec::new();
    vec.push(1);
    state.resume();
    pew::do_not_optimize(vec.get(1));
}

Panics

Panics if the state is paused.

[src]

impl<T: Default> State<T>
[src]

[src]

Returns the input. Either u64 (if no generator is specified) or a user specified T: Clone + Default where T is the return type of the last generator.

Examples

use pew::{self, State};
use std::vec::Vec;

fn bm_simple(state: &mut State<Vec<u64>>) {
    let mut vec = state.get_input();
    let n = vec.len();
    for i in 0..n {
        vec.push(i as u64);
    }
}

Panics

Panics if the state is paused.

Trait Implementations

Auto Trait Implementations

impl<T> Send for State<T> where
    T: Send

impl<T> Sync for State<T> where
    T: Sync