Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Perf.Time
Synopsis
- type Nanos = Integer
- defaultClock :: Clock
- toSecs :: Nanos -> Double
- nanosWith :: Clock -> IO Nanos
- nanos :: IO Nanos
- tick_ :: IO Nanos
- warmup :: Int -> IO ()
- tickWith :: Clock -> (a -> b) -> a -> IO (Nanos, b)
- tick :: (a -> b) -> a -> IO (Nanos, b)
- tickWHNF :: (a -> b) -> a -> IO (Nanos, b)
- tickLazy :: (a -> b) -> a -> IO (Nanos, b)
- tickForce :: (NFData a, NFData b) => (a -> b) -> a -> IO (Nanos, b)
- tickForceArgs :: NFData a => (a -> b) -> a -> IO (Nanos, b)
- tickIO :: IO a -> IO (Nanos, a)
- tickIOWith :: Clock -> IO a -> IO (Nanos, a)
- ticks :: Int -> (a -> b) -> a -> IO ([Nanos], b)
- ticksIO :: Int -> IO a -> IO ([Nanos], a)
- time :: Measure IO Nanos
- times :: Int -> Measure IO [Nanos]
- timesWith :: Clock -> Int -> Measure IO [Nanos]
- timesN :: Int -> Measure IO Nanos
- timesNWith :: Clock -> Int -> Measure IO Nanos
- stepTime :: StepMeasure IO Nanos
Documentation
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.
A single defaultClock
reading (note that the absolute value is not meaningful).
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.
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)
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
stepTime :: StepMeasure IO Nanos Source #
tick as a StepMeasure