[][src]Struct cliff::BinaryMinSearcher

pub struct BinaryMinSearcher { /* fields omitted */ }

An iterator that determines the minimum value of a system parameter by binary search.

use cliff::BinaryMinSearcher;

// First, we set the starting value for the parameter.
// This is the initial upper bound.
let mut limit = BinaryMinSearcher::until(512, 32);
// The initial upper bound is the first value we try.
assert_eq!(limit.next(), Some(512));
// Since we did not say that the system was overloaded,
// the iterator next produces half the value of the previous step.
assert_eq!(limit.next(), Some(256));
// Same thing again.
assert_eq!(limit.next(), Some(128));
// Now, let's say the system did not keep up with the last parameter value:
limit.overloaded();
// 128 is now a known _lower_ bound for the value, so the iteration
// continues the binary search between 128 and 256 (the last known-good value).
assert_eq!(limit.next(), Some(192));
// Let's say that succeeded.
// That means the cliff must lie between 128 and 192, so we try 160:
assert_eq!(limit.next(), Some(160));
// And if that failed ...
limit.overloaded();
// ... then the cliff must lie between 160 and 192, and so on.
// Ultimately, we reach the desired fidelity, which we set to 32.
// At that point, no more benchmark runs are performed.
assert_eq!(limit.next(), None);
// We can then ask the iterator what the final estimate is
assert_eq!(limit.estimate(), 160..192);

See also the crate-level documentation for details.

Implementations

impl BinaryMinSearcher[src]

pub fn until(start: usize, min_width: usize) -> Self[src]

Perform a minimum search starting at start, and ending when the minimum has been determined to within a range of min_width.

pub fn overloaded(&mut self)[src]

Indicate that the system could not keep up with the previous parameter yielded by Iterator::next.

This will affect what value the next call to Iterator::next yields.

This provides CliffSearch::overloaded without having to use the trait.

pub fn estimate(&self) -> Range<usize>[src]

Give the current estimate of the minimum parameter load the system-under-test can support.

This provides CliffSearch::estimate without having to use the trait.

Trait Implementations

impl CliffSearch for BinaryMinSearcher[src]

impl Clone for BinaryMinSearcher[src]

impl Debug for BinaryMinSearcher[src]

impl Iterator for BinaryMinSearcher[src]

type Item = usize

The type of the elements being iterated over.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.