Personal tools

Talk:Timing computations

From HaskellWiki

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