Talk:Timing computations

From HaskellWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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