perf-0.14.0.2: Performance methods and monad.
Safe HaskellSafe-Inferred
LanguageGHC2021

Perf.Time

Description

Use of Clock from the clock library to measure time performance of a computation.

Synopsis

Documentation

type Nanos = Integer Source #

A performance measure of number of nanoseconds.

defaultClock :: Clock Source #

MonotonicRaw is the default for macOS & linux, at around 42 nano time resolution, and a tick_ measurement of around 170 nanos. For Windows, ThreadCPUTime has a similar time resolution at 42 nanos and a tick_ of around 500 nanos.

toSecs :: Nanos -> Double Source #

Convert Nanos to seconds.

nanosWith :: Clock -> IO Nanos Source #

A single reading of a specific Clock.

nanos :: IO Nanos Source #

A single defaultClock reading (note that the absolute value is not meaningful).

tick_ :: IO Nanos Source #

tick_ measures the number of nanos it takes to read the clock.

warmup :: Int -> IO () Source #

Warm up the clock, to avoid a high first measurement. Without a warmup, one or more larger values can occur at the start of a measurement spree, and often are in the zone of an L2 miss.

tickWith :: Clock -> (a -> b) -> a -> IO (Nanos, b) Source #

tick from a specific Clock

tick :: (a -> b) -> a -> IO (Nanos, b) Source #

tick f a

  • strictly evaluates f and a to WHNF
  • reads the clock
  • strictly evaluates f a to WHNF
  • reads the clock
  • returns (nanos, f a)

tickWHNF :: (a -> b) -> a -> IO (Nanos, b) Source #

tickWHNF f a

  • reads the clock
  • strictly evaluates f a to WHNF (this may also kick off thunk evaluation in f or a which will also be captured in the cycle count)
  • reads the clock
  • returns (nanos, f a)

tickLazy :: (a -> b) -> a -> IO (Nanos, b) Source #

tickLazy f a

  • reads the clock
  • lazily evaluates f a
  • reads the clock
  • returns (nanos, f a)

tickForce :: (NFData a, NFData b) => (a -> b) -> a -> IO (Nanos, b) Source #

tickForce f a

  • deeply evaluates f and a,
  • reads the clock
  • deeply evaluates f a
  • reads the clock
  • returns (nanos, f a)

tickForceArgs :: NFData a => (a -> b) -> a -> IO (Nanos, b) Source #

tickForceArgs f a

  • deeply evaluates f and a,
  • reads the clock
  • strictly evaluates f a to WHNF
  • reads the clock
  • returns (nanos, f a)

tickIO :: IO a -> IO (Nanos, a) Source #

measures an IO a

tickIOWith :: Clock -> IO a -> IO (Nanos, a) Source #

measures an IO a

ticks :: Int -> (a -> b) -> a -> IO ([Nanos], b) Source #

n measurements of a tick

returns a list of Nanos and the last evaluated f a

ticksIO :: Int -> IO a -> IO ([Nanos], a) Source #

n measurements of a tickIO

returns an IO tuple; list of Nanos and the last evaluated f a

times :: Int -> Measure IO [Nanos] Source #

tick as a multi-Measure

timesWith :: Clock -> Int -> Measure IO [Nanos] Source #

tickWith as a multi-Measure

timesN :: Int -> Measure IO Nanos Source #

tickWith for n repeated applications

timesNWith :: Clock -> Int -> Measure IO Nanos Source #

tickWith for n repeated applications