criterion- Robust, reliable performance measurement and analysis

Copyright(c) 2009-2014 Bryan O'Sullivan
Safe HaskellNone



Benchmark measurement code.



initializeTime :: IO () Source

Set up time measurement.

getTime :: IO Double Source

Return the current wallclock time, in seconds since some arbitrary time.

You must call initializeTime once before calling this function!

getCPUTime :: IO Double Source

Return the amount of elapsed CPU time, combining user and kernel (system) time into a single measure.

getCycles :: IO Word64 Source

Read the CPU cycle counter.

getGCStats :: IO (Maybe GCStats) Source

Try to get GC statistics, bearing in mind that the GHC runtime will throw an exception if statistics collection was not enabled using "+RTS -T".

secs :: Double -> String Source

Convert a number of seconds to a string. The string will consist of four decimal places, followed by a short description of the time units.

measure Source


:: Benchmarkable

Operation to benchmark.

-> Int64

Number of iterations.

-> IO (Measured, Double) 

Measure the execution of a benchmark a given number of times.

runBenchmark Source


:: Benchmarkable 
-> Double

Lower bound on how long the benchmarking process should take. In practice, this time limit may be exceeded in order to generate enough data to perform meaningful statistical analyses.

-> IO (Vector Measured, Double) 

Run a single benchmark, and return measurements collected while executing it, along with the amount of time the measurement process took.

measured :: Measured Source

An empty structure.

applyGCStats Source


:: Maybe GCStats

Statistics gathered at the end of a run.

-> Maybe GCStats

Statistics gathered at the beginning of a run.

-> Measured

Value to "modify".

-> Measured 

Apply the difference between two sets of GC statistics to a measurement.

threshold :: Double Source

The amount of time a benchmark must run for in order for us to have some trust in the raw measurement.

We set this threshold so that we can generate enough data to later perform meaningful statistical analyses.

The threshold is 30 milliseconds. One use of runBenchmark must accumulate more than 300 milliseconds of total measurements above this threshold before it will finish.