Trait tiny_bench::Timeable

source ·
pub trait Timeable<It, T>: Sized
where It: Iterator<Item = T>,
{ // Required methods fn timed_labeled( self, label: &'static str, ) -> TimedIterator<It, T, SimpleStdout> ; fn timed_persisted_labeled( self, label: &'static str, ) -> TimedIterator<It, T, ComparedStdout> ; // Provided methods fn timed(self) -> TimedIterator<It, T, SimpleStdout> { ... } fn timed_persisted(self) -> TimedIterator<It, T, ComparedStdout> { ... } }
Expand description

A trait for allowing iterators to be used as timers

Required Methods§

source

fn timed_labeled( self, label: &'static str, ) -> TimedIterator<It, T, SimpleStdout>

Time this iterator with a specified label

use tiny_bench::Timeable;
let v: Vec<i32> = (0..100)
    .timed_labeled("my_iterator_test")
    .collect();
// Prints results when the iterator has been drained
assert_eq!(100, v.len());
source

fn timed_persisted_labeled( self, label: &'static str, ) -> TimedIterator<It, T, ComparedStdout>

Time this iterator with a custom label to separate different runs for comparison

Provided Methods§

source

fn timed(self) -> TimedIterator<It, T, SimpleStdout>

Time this iterator with an anonymous label

use tiny_bench::Timeable;
let v: Vec<i32> = (0..100)
    .timed()
    .collect();
// Prints results when the iterator has been drained
assert_eq!(100, v.len());
Examples found in repository?
examples/time_iterator.rs (line 9)
4
5
6
7
8
9
10
11
12
pub fn main() {
    let v = (0..100)
        .inspect(|_a| {
            my_expensive_call();
        })
        .timed()
        .max();
    assert_eq!(99, v.unwrap());
}
source

fn timed_persisted(self) -> TimedIterator<It, T, ComparedStdout>

Time this iterator with an anonymous label and persist the result so that other anonymous time results will be compared with it when they run next

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<It, T> Timeable<It, T> for It
where It: Iterator<Item = T>,