| Copyright | (c) 2009-2014 Bryan O'Sullivan |
|---|---|
| License | BSD-style |
| Maintainer | bos@serpentine.com |
| Stability | experimental |
| Portability | GHC |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Gauge.Main
Description
Wrappers for compiling and running benchmarks quickly and easily.
See defaultMain below for an example.
- defaultMain :: [Benchmark] -> IO ()
- defaultMainWith :: Config -> [Benchmark] -> IO ()
- runMode :: Mode -> Config -> [String] -> [Benchmark] -> IO ()
- benchmark :: Benchmarkable -> IO ()
- benchmarkWith :: Config -> Benchmarkable -> IO ()
- module Gauge.Benchmark
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.
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.
module Gauge.Benchmark