Enum codspeed_criterion_compat::BatchSize

source ·
pub enum BatchSize {
    SmallInput,
    LargeInput,
    PerIteration,
    NumBatches(u64),
    NumIterations(u64),
    // some variants omitted
}
Expand description

Argument to Bencher::iter_batched and Bencher::iter_batched_ref which controls the batch size.

Generally speaking, almost all benchmarks should use SmallInput. If the input or the result of the benchmark routine is large enough that SmallInput causes out-of-memory errors, LargeInput can be used to reduce memory usage at the cost of increasing the measurement overhead. If the input or the result is extremely large (or if it holds some limited external resource like a file handle), PerIteration will set the number of iterations per batch to exactly one. PerIteration can increase the measurement overhead substantially and should be avoided wherever possible.

Each value lists an estimate of the measurement overhead. This is intended as a rough guide to assist in choosing an option, it should not be relied upon. In particular, it is not valid to subtract the listed overhead from the measurement and assume that the result represents the true runtime of a function. The actual measurement overhead for your specific benchmark depends on the details of the function you’re benchmarking and the hardware and operating system running the benchmark.

With that said, if the runtime of your function is small relative to the measurement overhead it will be difficult to take accurate measurements. In this situation, the best option is to use Bencher::iter which has next-to-zero measurement overhead.

Variants§

§

SmallInput

SmallInput indicates that the input to the benchmark routine (the value returned from the setup routine) is small enough that millions of values can be safely held in memory. Always prefer SmallInput unless the benchmark is using too much memory.

In testing, the maximum measurement overhead from benchmarking with SmallInput is on the order of 500 picoseconds. This is presented as a rough guide; your results may vary.

§

LargeInput

LargeInput indicates that the input to the benchmark routine or the value returned from that routine is large. This will reduce the memory usage but increase the measurement overhead.

In testing, the maximum measurement overhead from benchmarking with LargeInput is on the order of 750 picoseconds. This is presented as a rough guide; your results may vary.

§

PerIteration

PerIteration indicates that the input to the benchmark routine or the value returned from that routine is extremely large or holds some limited resource, such that holding many values in memory at once is infeasible. This provides the worst measurement overhead, but the lowest memory usage.

In testing, the maximum measurement overhead from benchmarking with PerIteration is on the order of 350 nanoseconds or 350,000 picoseconds. This is presented as a rough guide; your results may vary.

§

NumBatches(u64)

NumBatches will attempt to divide the iterations up into a given number of batches. A larger number of batches (and thus smaller batches) will reduce memory usage but increase measurement overhead. This allows the user to choose their own tradeoff between memory usage and measurement overhead, but care must be taken in tuning the number of batches. Most benchmarks should use SmallInput or LargeInput instead.

§

NumIterations(u64)

NumIterations fixes the batch size to a constant number, specified by the user. This allows the user to choose their own tradeoff between overhead and memory usage, but care must be taken in tuning the batch size. In general, the measurement overhead of NumIterations will be larger than that of NumBatches. Most benchmarks should use SmallInput or LargeInput instead.

Trait Implementations§

source§

impl Clone for BatchSize

source§

fn clone(&self) -> BatchSize

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BatchSize

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Hash for BatchSize

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for BatchSize

source§

fn eq(&self, other: &BatchSize) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for BatchSize

source§

impl Eq for BatchSize

source§

impl StructuralPartialEq for BatchSize

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.