criterion-0.8.1.0: Robust, reliable performance measurement and analysis

Copyright(c) 2009, 2010, 2011 Bryan O'Sullivan
LicenseBSD-style
Maintainerbos@serpentine.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell98

Criterion

Description

Core benchmarking code.

Synopsis

Documentation

class Benchmarkable a where

A benchmarkable function or action.

Methods

run

Arguments

:: a

The function or action to benchmark.

-> Int

The number of times to run or evaluate it.

-> IO () 

Run a function or action the specified number of times.

data Benchmark

A benchmark may consist of either a single Benchmarkable item with a name, created with bench, or a (possibly nested) group of Benchmarks, created with bgroup.

Instances

data Pure

A container for a pure function to benchmark, and an argument to supply to it each time it is evaluated.

Instances

nf :: NFData b => (a -> b) -> a -> Pure

Apply an argument to a function, and evaluate the result to head normal form (NF).

whnf :: (a -> b) -> a -> Pure

Apply an argument to a function, and evaluate the result to weak head normal form (WHNF).

nfIO :: NFData a => IO a -> IO ()

Perform an action, then evaluate its result to head normal form. This is particularly useful for forcing a lazy IO action to be completely performed.

whnfIO :: IO a -> IO ()

Perform an action, then evaluate its result to weak head normal form (WHNF). This is useful for forcing an IO action whose result is an expression to be evaluated down to a more useful value.

bench

Arguments

:: Benchmarkable b 
=> String

A name to identify the benchmark.

-> b 
-> Benchmark 

Create a single benchmark.

bcompare :: [Benchmark] -> Benchmark

Compare benchmarks against a reference benchmark (The first bench in the given list).

The results of the comparisons are written to a CSV file specified using the -r command line flag. The CSV file uses the following format:

Reference,Name,% faster than the reference

bgroup

Arguments

:: String

A name to identify the group of benchmarks.

-> [Benchmark]

Benchmarks to group under this name.

-> Benchmark 

Group several benchmarks together under a common name.

runBenchmark :: Benchmarkable b => Environment -> b -> Criterion Sample

Run a single benchmark, and return timings measured when executing it.

runAndAnalyse

Arguments

:: (String -> Bool)

A predicate that chooses whether to run a benchmark by its name.

-> Environment 
-> Benchmark 
-> Criterion () 

Run, and analyse, one or more benchmarks.

runNotAnalyse

Arguments

:: (String -> Bool)

A predicate that chooses whether to run a benchmark by its name.

-> Benchmark 
-> Criterion ()