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
- Default
if a generator(s) is defined (where
T` is the return type of the final specified generator).
Methods
impl<T> State<T>
[src]
pub fn pause(&mut self)
[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.
pub fn resume(&mut self)
[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 already paused.
impl<T: Default> State<T>
[src]
pub fn get_input(&mut self) -> T
[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.