criterion-1.2.6.0: Robust, reliable performance measurement and analysis

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

Criterion.Measurement

Contents

Description

Benchmark measurement code.

Synopsis

Documentation

initializeTime :: IO () Source #

Set up time measurement.

getTime :: IO Double Source #

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

You must call initializeTime once before calling this function!

getCPUTime :: IO Double Source #

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

getCycles :: IO Word64 Source #

Read the CPU cycle counter.

getGCStatistics :: IO (Maybe GCStatistics) Source #

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

data GCStatistics Source #

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 has. Since GCStats was marked as deprecated and will be removed in GHC 8.4, we use GCStatistics to provide a backwards-compatible view of GC statistics.

Constructors

GCStatistics 

Fields

Instances

Eq GCStatistics Source # 
Data GCStatistics Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GCStatistics -> c GCStatistics #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c GCStatistics #

toConstr :: GCStatistics -> Constr #

dataTypeOf :: GCStatistics -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c GCStatistics) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c GCStatistics) #

gmapT :: (forall b. Data b => b -> b) -> GCStatistics -> GCStatistics #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GCStatistics -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GCStatistics -> r #

gmapQ :: (forall d. Data d => d -> u) -> GCStatistics -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> GCStatistics -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> GCStatistics -> m GCStatistics #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GCStatistics -> m GCStatistics #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GCStatistics -> m GCStatistics #

Read GCStatistics Source # 
Show GCStatistics Source # 
Generic GCStatistics Source # 

Associated Types

type Rep GCStatistics :: * -> * #

type Rep GCStatistics Source # 
type Rep GCStatistics = D1 (MetaData "GCStatistics" "Criterion.Measurement" "criterion-1.2.6.0-DEKNoApFROw9iLVCJj626B" False) (C1 (MetaCons "GCStatistics" PrefixI True) ((:*:) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "gcStatsBytesAllocated") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int64)) (S1 (MetaSel (Just Symbol "gcStatsNumGcs") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int64))) ((:*:) (S1 (MetaSel (Just Symbol "gcStatsMaxBytesUsed") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int64)) (S1 (MetaSel (Just Symbol "gcStatsNumByteUsageSamples") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int64)))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "gcStatsCumulativeBytesUsed") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int64)) (S1 (MetaSel (Just Symbol "gcStatsBytesCopied") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int64))) ((:*:) (S1 (MetaSel (Just Symbol "gcStatsCurrentBytesUsed") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int64)) (S1 (MetaSel (Just Symbol "gcStatsCurrentBytesSlop") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int64))))) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "gcStatsMaxBytesSlop") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int64)) (S1 (MetaSel (Just Symbol "gcStatsPeakMegabytesAllocated") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int64))) ((:*:) (S1 (MetaSel (Just Symbol "gcStatsMutatorCpuSeconds") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Double)) (S1 (MetaSel (Just Symbol "gcStatsMutatorWallSeconds") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Double)))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "gcStatsGcCpuSeconds") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Double)) (S1 (MetaSel (Just Symbol "gcStatsGcWallSeconds") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Double))) ((:*:) (S1 (MetaSel (Just Symbol "gcStatsCpuSeconds") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Double)) (S1 (MetaSel (Just Symbol "gcStatsWallSeconds") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Double)))))))

secs :: Double -> String Source #

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.

measure Source #

Arguments

:: Benchmarkable

Operation to benchmark.

-> Int64

Number of iterations.

-> IO (Measured, Double) 

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

runBenchmark Source #

Arguments

:: Benchmarkable 
-> 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.

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

runBenchmarkable :: Benchmarkable -> Int64 -> (a -> a -> a) -> (IO () -> IO a) -> IO a Source #

measured :: Measured Source #

An empty structure.

applyGCStatistics Source #

Arguments

:: Maybe GCStatistics

Statistics gathered at the end of a run.

-> Maybe GCStatistics

Statistics gathered at the beginning of a run.

-> Measured

Value to "modify".

-> Measured 

Apply the difference between two sets of GC statistics to a measurement.

threshold :: Double Source #

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.

Deprecated

getGCStats :: IO (Maybe GCStats) Source #

Deprecated: GCStats has been deprecated in GHC 8.2. As a consequence,getGCStats has also been deprecated in favor of getGCStatistics.getGCStats will be removed in the next major criterion release.

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

applyGCStats Source #

Arguments

:: Maybe GCStats

Statistics gathered at the end of a run.

-> Maybe GCStats

Statistics gathered at the beginning of a run.

-> Measured

Value to "modify".

-> Measured 

Deprecated: GCStats has been deprecated in GHC 8.2. As a consequence,applyGCStats has also been deprecated in favor of applyGCStatistics.applyGCStats will be removed in the next major criterion release.

Apply the difference between two sets of GC statistics to a measurement.