gauge-0.2.0: small framework for performance measurement and analysis

Copyright(c) 2009-2014 Bryan O'Sullivan
LicenseBSD-style
Maintainerbos@serpentine.com
Stabilityexperimental
PortabilityGHC
Safe HaskellTrustworthy
LanguageHaskell2010

Gauge.Main

Contents

Description

Wrappers for compiling and running benchmarks quickly and easily. See defaultMain below for an example.

Synopsis

Turning a suite of benchmarks into a program

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

An entry point that can be used as a main function.

import Gauge.Main

fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)

main = defaultMain [
       bgroup "fib" [ bench "10" $ whnf fib 10
                    , bench "35" $ whnf fib 35
                    , bench "37" $ whnf fib 37
                    ]
                   ]

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

An entry point that can be used as a main function, with configurable defaults.

Example:

import Gauge.Main.Options
import Gauge.Main

myConfig = defaultConfig {
             -- Do not GC between runs.
             forceGC = False
           }

main = defaultMainWith myConfig [
         bench "fib 30" $ whnf fib 30
       ]

If you save the above example as "Fib.hs", you should be able to compile it as follows:

ghc -O --make Fib

Run "Fib --help" on the command line to get a list of command line options.

runMode :: Mode -> Config -> [String] -> [Benchmark] -> IO () Source #

Run a set of Benchmarks with the given Mode.

This can be useful if you have a Mode from some other source (e.g. from a one in your benchmark driver's command-line parser).

Running Benchmarks Interactively

benchmark :: Benchmarkable -> IO () Source #

Run a benchmark interactively with default config, and analyse its performance.

benchmarkWith :: Config -> Benchmarkable -> IO () Source #

Run a benchmark interactively with supplied config, and analyse its performance.