packages feed

debug-time 0.1.0.0 → 0.1.0.1

raw patch · 2 files changed

+31/−3 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

debug-time.cabal view
@@ -1,7 +1,7 @@ name:                debug-time-version:             0.1.0.0+version:             0.1.0.1 synopsis:            Debug.Trace equivalent for timing computations-description:         Please see README.md+description:         Debug.Trace equivalent for timing computations homepage:            http://github.com/LukaHorvat/debug-time#readme license:             MIT license-file:        LICENSE
src/Debug/Time.hs view
@@ -1,3 +1,31 @@+-- | 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)
+-- @
 {-# OPTIONS_GHC -fno-cse -fno-full-laziness #-}
 module Debug.Time (startTimer, traceTimer, restartTimer, initializeTimers) where
 
@@ -24,7 +52,7 @@         Nothing -> error $ "Attempting to read the timer '" ++ name ++ "' that has not been started"
         Just t  -> return $! timeSpecAsNanoSecs (diffTimeSpec now t)
 
--- | Initializes the timer store. This makes the first measurement more reliable."
+-- | Initializes the timer store. This makes the first measurement more reliable.
 initializeTimers :: IO ()
 initializeTimers = void $! Ref.readIORef timers