Safe Haskell | None |
---|---|
Language | Haskell2010 |
Debug.Time
Description
Here's how you can use this package
module Main where import Debug.Time -- | Naive implementation fibs :: [Int] fibs = map (fibAt . maybeTimer) [1..] where maybeTimer 10 = startTimer "10-30" 10 maybeTimer 30 = traceTimer "10-30" 30 maybeTimer 20 = startTimer "20-40" 20 maybeTimer 40 = traceTimer "20-40" 40 maybeTimer n = n fibAt :: Int -> Int fibAt 1 = 1 fibAt 2 = 1 fibAt n = fibAt (n - 1) + fibAt (n - 2) main :: IO () main = do initializeTimers putStrLn "Calculating the first 40 fibonacci numbers while tracing the time elapsed between" putStrLn "the computations 10-30 and 20-40" mapM_ print (take 40 fibs)
- startTimer :: String -> a -> a
- traceTimer :: String -> a -> a
- restartTimer :: String -> a -> a
- initializeTimers :: IO ()
Documentation
startTimer :: String -> a -> a Source
Ties the evaluation of the value with the start of a timer with the given name.
traceTimer :: String -> a -> a Source
Ties the evaluation of the value with an action tracing the elapsed time since the start of the timer.
restartTimer :: String -> a -> a Source
Synonym for startTimer.
initializeTimers :: IO () Source
Initializes the timer store. This makes the first measurement more reliable.