chronos-bench-0.2.0.2: Benchmarking tool with focus on comparing results.

Safe HaskellNone
LanguageHaskell2010

Chronos.Bench

Contents

Description

Library to comparatively benchmark pure functions, impure functions and shell commands with lazy precision.

Synopsis

Benchmark

defaultMain :: [Benchmark] -> IO () Source #

Main function for running a list of benchmarks. It also allows to specify options via commandline.

defaultMain [bench "not True" not True, bench "id True" id True]

bench :: NFData b => String -> (a -> b) -> a -> Benchmark Source #

Construct a benchmark of a name, a pure function and an argument.

bench "reverse abc" reverse "abc"

benchIO :: String -> IO a -> Benchmark Source #

Construct a benchmark of a name and an impure function.

benchIO "ioref" (newIORef () >>= readIORef)

benchShell :: String -> String -> Benchmark Source #

Construct a benchmark of a name and a shell command.

benchShell "sleep is slow" "sleep 0"

Configuration

defaultMainWith :: Config -> [Benchmark] -> IO () Source #

Configurable main function for running a list of benchmarks.

defaultMainWith defaultConfig {hideBar = True} [bench "id ()" id ()]

defaultConfig :: Config Source #

Default configuration. Use this combined with record updates to ensure compatibility with future releases.

data Config Source #

Options wich can be specified on the command line or with defaultMainWith.

Constructors

Config 

Fields

  • hideBar :: Bool

    Hide the bar indicating relative performance.

  • sameLine :: Bool

    Print the analysis on the same line as the command.

  • hideDetails :: Bool

    Hide standard deviation and number of samples.

  • printOnce :: Bool

    Print only once the analysis. This is will print the analysis on timeout, maximal relative error or ctrl-c.

  • sortByMean :: Bool

    Sort benchmarks by mean duration.

  • simple :: Bool

    Don't colorize output and don't use unicode.

  • confidence :: Double

    Factor by which the standard error will be multiplied for calculating confidence intervals (default is 6).

  • timeout :: Maybe Double

    Timeout after which the program is terminated. It finishes the currently running benchmark.

  • relativeError :: Maybe Double

    After every benchmark has got a relative error (calculated via confidence interval) below DOUBLE the program is terminated.

Instances
Eq Config Source # 
Instance details

Defined in Chronos.Bench

Methods

(==) :: Config -> Config -> Bool #

(/=) :: Config -> Config -> Bool #

Ord Config Source # 
Instance details

Defined in Chronos.Bench

Read Config Source # 
Instance details

Defined in Chronos.Bench

Show Config Source # 
Instance details

Defined in Chronos.Bench

Testing

isEqualTo :: Benchmark -> Benchmark -> IO Bool Source #

Determine whether two benchmarks have got the same performance. It runs each benchmark until their confidence intervals don't overlap - in which case False is returned - or are no bigger than 1% of the mean - in which case True is returned.

This function is meant to be used in test suites as infix function.

benchShell "echo" "echo" `isEqualTo` benchShell "sleep 0" "sleep 0"

isFasterThan :: Benchmark -> Benchmark -> IO Bool Source #

Determine whether a benchmark is faster than another. It runs each benchmark until their confidence intervals don't overlap or are no bigger than 1% of the mean. If the confidence intervals don't overlap and the mean of the first is lower True will be returned. Otherwise False.

This function is meant to be used in test suites as infix function.

benchShell "echo" "echo" `isFasterThan` benchShell "sleep 0" "sleep 0"

Analysis

standardDeviation :: Analysis -> Double Source #

Calculate the standard deviation of an Analysis.

standardError :: Analysis -> Double Source #

Calculate the standard error of an Analysis.

variance :: Analysis -> Rational Source #

Calculate the variance of an Analysis.

step :: Benchmark -> IO Benchmark Source #

Run the benchmark once and update its analysis. For functions with very low runtimes multiple runs will be executed.

data Benchmark Source #

Name, current analysis and function of a benchmark.

Constructors

Benchmark 

data Analysis Source #

Collected data from benchmark runs.

Instances
Eq Analysis Source # 
Instance details

Defined in Chronos.Bench

Ord Analysis Source # 
Instance details

Defined in Chronos.Bench

Read Analysis Source # 
Instance details

Defined in Chronos.Bench

Show Analysis Source # 
Instance details

Defined in Chronos.Bench