perf-0.10.0: Low-level run time measurement.
Safe HaskellNone
LanguageHaskell2010

Perf.Time

Description

tick uses the rdtsc chipset to measure time performance of a computation.

The measurement unit is one oscillation of the chip crystal as measured by the rdtsc instruction which inspects the TSC register.

For reference, a computer with a frequency of 2 GHz means that one cycle is equivalent to 0.5 nanoseconds.

Synopsis

Documentation

tick_ :: IO Cycles Source #

tick_ measures the number of cycles it takes to read the rdtsc chip twice: the difference is then how long it took to read the clock the second time.

warmup :: Int -> IO () Source #

Warm up the register, 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 (Cycles, b) Source #

tick f a

  • strictly evaluates f and a to WHNF
  • starts the cycle counter
  • strictly evaluates f a to WHNF
  • stops the cycle counter
  • returns (number of cycles, f a)

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

tickWHNF f a

  • starts the cycle counter
  • 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)
  • stops the cycle counter
  • returns (number of cycles, f a)

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

tickLazy f a

  • starts the cycle counter
  • lazily evaluates f a
  • stops the cycle counter
  • returns (number of cycles, f a)

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

tickForce f a

  • deeply evaluates f and a,
  • starts the cycle counter
  • deeply evaluates f a
  • stops the cycle counter
  • returns (number of cycles, f a)

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

tickForceArgs f a

  • deeply evaluates f and a,
  • starts the cycle counter
  • strictly evaluates f a to WHNF
  • stops the cycle counter
  • returns (number of cycles, f a)

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

measures an IO a

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

n measurements of a tick

returns a list of Cycles and the last evaluated f a

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

n measurements of a tickIO

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

newtype Cycles Source #

Clock count.

Constructors

Cycles 

Fields

Instances

Instances details
Enum Cycles Source # 
Instance details

Defined in Perf.Time

Eq Cycles Source # 
Instance details

Defined in Perf.Time

Methods

(==) :: Cycles -> Cycles -> Bool #

(/=) :: Cycles -> Cycles -> Bool #

Integral Cycles Source # 
Instance details

Defined in Perf.Time

Num Cycles Source # 
Instance details

Defined in Perf.Time

Ord Cycles Source # 
Instance details

Defined in Perf.Time

Read Cycles Source # 
Instance details

Defined in Perf.Time

Real Cycles Source # 
Instance details

Defined in Perf.Time

Show Cycles Source # 
Instance details

Defined in Perf.Time

Semigroup Cycles Source # 
Instance details

Defined in Perf.Time

Monoid Cycles Source # 
Instance details

Defined in Perf.Time

cputime :: StepMeasure IO Integer Source #

a measure using getCPUTime from System.CPUTime (unit is picoseconds)

clocktime :: StepMeasure IO Double Source #

a measure using getCurrentTime (unit is seconds)

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

tick as a multi-Measure