Talk:Timing computations

From HaskellWiki
Revision as of 23:32, 28 October 2015 by Dsf (talk | contribs) (Created page with "How about: import Data.Time time :: IO t -> IO t time a = do start <- getCurrentTime v <- a end <- getCurrentTime putStrLn $ "Computation...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How about:

   import Data.Time
   time :: IO t -> IO t
   time a = do
     start <- getCurrentTime
     v <- a
     end <- getCurrentTime
     putStrLn $ "Computation time: " ++ show (diffUTCTime end start)
     return v