Module

Performance.Minibench

This module provides the bench function, which prints a short summary of the running times of a synchronous function to the console.

For benchmarking tasks which require finer accuracy, or graphs as output, consider using purescript-benchotron instead.

#bench

bench :: forall a. (Unit -> a) -> Effect Unit

Estimate the running time of a function and print a summary to the console, by running the function 1000 times.

For example:

> import Data.Array
> import Data.Foldable
> import Performance.Minibench
> bench \_ -> sum (1 .. 10000)

mean   = 414.00 μs
stddev = 494.82 μs

#benchWith

benchWith :: forall a. Int -> (Unit -> a) -> Effect Unit

Estimate the running time of a function and print a summary to the console, specifying the number of samples to take. More samples will give a better estimate of both mean and standard deviation, but will increase running time.

To increase benchmark accuracy by forcing garbage collection before the benchmark is run, node should be invoked with the '--expose-gc' flag.

#benchWith'

benchWith' :: forall a. Int -> (Unit -> a) -> Effect BenchResult

#BenchResult

type BenchResult = { max :: Number, mean :: Number, min :: Number, stdDev :: Number }

#withUnits

Modules