License | MIT |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Miniterion
Description
Simple benchmarking utilities with API subset of criterion (and also a subset of gauge and tasty-bench).
The goal of this package is to provide simple and lightweight benchmark utilities with less amount of codes and dependency packages. For robust and feature rich benchmarking utility, use the other packages mentioned above.
This is the only module exposed from the miniterion
package. The
dependency packages of miniterion
are kept small (at the moment
base
and deepseq
) to make the compilation time and installation
time short, by dropping some functionalities and efficiencies.
Synopsis
- data Benchmark
- data Benchmarkable
- env :: NFData env => IO env -> (env -> Benchmark) -> Benchmark
- envWithCleanup :: NFData env => IO env -> (env -> IO a) -> (env -> Benchmark) -> Benchmark
- perBatchEnv :: (NFData env, NFData b) => (Word64 -> IO env) -> (env -> IO b) -> Benchmarkable
- perBatchEnvWithCleanup :: (NFData env, NFData b) => (Word64 -> IO env) -> (Word64 -> env -> IO ()) -> (env -> IO b) -> Benchmarkable
- perRunEnv :: (NFData env, NFData b) => IO env -> (env -> IO b) -> Benchmarkable
- perRunEnvWithCleanup :: (NFData env, NFData b) => IO env -> (env -> IO ()) -> (env -> IO b) -> Benchmarkable
- toBenchmarkable :: (Word64 -> IO ()) -> Benchmarkable
- bench :: String -> Benchmarkable -> Benchmark
- bgroup :: String -> [Benchmark] -> Benchmark
- nf :: NFData b => (a -> b) -> a -> Benchmarkable
- whnf :: (a -> b) -> a -> Benchmarkable
- nfIO :: NFData a => IO a -> Benchmarkable
- whnfIO :: IO a -> Benchmarkable
- nfAppIO :: NFData b => (a -> IO b) -> a -> Benchmarkable
- whnfAppIO :: (a -> IO b) -> a -> Benchmarkable
- defaultMain :: [Benchmark] -> IO ()
- benchmark :: Benchmarkable -> IO ()
Types
Benchmarks are simple tree structure with names, and additional
information to support envWithCleanup
.
Drop-in replacement for Criterion.Benchmark
.
data Benchmarkable Source #
Creating benchmark suite
Arguments
:: NFData env | |
=> IO env | Action to create the environment. |
-> (env -> Benchmark) | A function returning benchmark. |
-> Benchmark |
Run a benchmark (or collection of benchmarks) in the given environment, usually reading large input data from file.
Drop-in replacement for Criterion.env
.
Arguments
:: NFData env | |
=> IO env | Action to create the environment. |
-> (env -> IO a) | Action to cleanup the environment. |
-> (env -> Benchmark) | A function returning benchmark. |
-> Benchmark |
Similar to env
, but includes an additional argument to clean up
the environment.
Drop-in replacement for Criterion.envWithCleanup
.
Arguments
:: (NFData env, NFData b) | |
=> (Word64 -> IO env) | Action to create an environment for a batch of N runs. |
-> (env -> IO b) | Benchmark body function. |
-> Benchmarkable |
Create a Benchmarkable where a fresh environment is allocated for every batch of runs of the benchmarkable.
Drop-in replacement for Criterion.perBatchEnv
.
perBatchEnvWithCleanup Source #
Arguments
:: (NFData env, NFData b) | |
=> (Word64 -> IO env) | Action to create an environment for a batch of N runs. |
-> (Word64 -> env -> IO ()) | Action to cleanup the environment. |
-> (env -> IO b) | Benchmark body function. |
-> Benchmarkable |
Same as perBatchEnv
, but but allows for an additional callback
to clean up the environment.
Drop-in replacement for Criterion.perBatchEnvWithCleanup
.
Arguments
:: (NFData env, NFData b) | |
=> IO env | Action to create an environment for a single run. |
-> (env -> IO b) | Benchmark body function. |
-> Benchmarkable |
Create a Benchmarkable where a fresh environment is allocated for every run of the operation to benchmark.
Drop-in replacement for Criterion.perRunEnv
.
NOTE: This function does not work well (or not work at all) if
the time spent in the initialization work is relatively long
compared to the time spent in the benchmark body function. In such
case, consider modifying the benchmark body function to spend more
elapsed time, or switch to the criterion
package.
Arguments
:: (NFData env, NFData b) | |
=> IO env | Action to create an environment for a single run. |
-> (env -> IO ()) | Action to cleanup the environment. |
-> (env -> IO b) | Benchmark body function. |
-> Benchmarkable |
Same as perBatchEnv
, but allows for an additional callback to
clean up the environment.
Drop-in replacement for Criterion.perRunEnvWithCleanup
.
NOTE: See the note in perRunEnv
.
toBenchmarkable :: (Word64 -> IO ()) -> Benchmarkable Source #
Construct a Benchmarkable
value from an impure action, where
the Word64
parameter indicates the number of times to run the
action.
Drop-in replacement for Criterion.toBenchmarkable
.
Arguments
:: String | Name of this benchmark. |
-> Benchmarkable | Benchmark target. |
-> Benchmark |
Attach a name to Benchmarkable
.
The type signature is compatible with
Criterion.bench
.
Running a benchmark
nf :: NFData b => (a -> b) -> a -> Benchmarkable Source #
whnf :: (a -> b) -> a -> Benchmarkable Source #
whnfIO :: IO a -> Benchmarkable Source #
whnfAppIO :: (a -> IO b) -> a -> Benchmarkable Source #
Turning a suite of benchmarks into a program
defaultMain :: [Benchmark] -> IO () Source #
Run benchmarks and report results, providing an interface
compatible with Criterion.Main.defaultMain
.