Crate tiny_bench

source ·
Expand description

tiny-bench, a tiny benchmarking library. The crate is divided into two sections, benchmarking and timing. Benchmarking provides tools to measure code execution, show statistics about that execution, and compare those statistics to previous runs. Timing provides tools to time code. Timing how long a closure runs, or how long an iterator runs.

Structs

  • Struct containing all of the configuration options for a benchmark.
  • An iterator that wraps another iterator and times each call to next
  • Data collected after a timed run

Traits

  • A trait for allowing iterators to be used as timers

Functions

  • Will run the closure and print statistics from the benchmarking to stdout. Will persist results under the anonymous label which is shared, making comparisons impossible if running more than one (different) benchmark on the same project, ie. benching two different functions
  • Will run the closure with a label, running with a label enables comparisons for subsequent runs.
  • Will run the benchmark with the supplied configuration
  • Will run the benchmark with the supplied configuration and a label
  • Fitting if some setup for the benchmark is required, and that setup should not be timed. The setup will be run prior to each benchmarking run.
  • Run bench with setup and configuration
  • Run bench with setup, configuration, and a label
  • Run bench with setup and a label
  • Everything in this module is more or less copied from criterion.rs with some rewrites to make it fit, the license is included in this file’s directory A function that is opaque to the optimizer, used to prevent the compiler from optimizing away computations in a benchmark.
  • The simplest possible timed function that just runs some FnMut closure and returns the time it took
  • Drains an iterator and calls the closure with the yielded value, timing the closure’s execution.
  • Runs some closure n times and returns the data gathered