HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulecriterion-measurement-0.2.3.0Haskell2010

Criterion.Measurement

Benchmark measurement code.

  • 1 type
  • 13 values
valueinitializeTime :: IO ()
#

Set up time measurement.

criterion measures time using OS-specific APIs whenever possible for efficiency. On certain operating systems, such as macOS and Windows, one must explicitly initialize a timer (which initializeTime accomplishes) before one can actually measure the current time (which getTime accomplishes).

It is imperative that you call initializeTime before calling getTime. (See this bug report for an example of what can happen if you do not do so.) All of the IO-returning functions in Criterion.Main make sure that this is done, but other functions (such as those in Criterion.Measurement) do not guarantee this unless otherwise stated.

valuegetTime :: IO Double
#

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

You must call initializeTime once before calling this function! Refer to the documentation for initializeTime for more details.

valuegetCPUTime :: IO Double
#

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

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".

If you need guaranteed up-to-date stats, call performGC first.

datadata GCStatistics
#

Statistics about memory usage and the garbage collector. Apart from gcStatsCurrentBytesUsed and gcStatsCurrentBytesSlop all are cumulative values since the program started.

GCStatistics is cargo-culted from the GCStats data type that GHC.Stats used to export. Since GCStats was removed in GHC 8.4, criterion uses GCStatistics to provide a backwards-compatible view of GC statistics.

Constructors

Instances6Eq, Data, Read, Show, Generic, Rep
valuesecs :: Double -> String
#

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.

valuemeasure
  1. :: Benchmarkable

    Operation to benchmark.

  2. -> Int64

    Number of iterations.

  3. -> IO (Measured, Double)
#

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

This function initializes the timer before measuring time (refer to the documentation for initializeTime for more details).

valuerunBenchmark
  1. :: Benchmarkable
  2. -> 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.

  3. -> 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.

This function initializes the timer before measuring time (refer to the documentation for initializeTime for more details).

valuethreshold :: Double
#

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.