Ticket #5865: threadDelay-clock-change.hs

File threadDelay-clock-change.hs, 346 bytes (added by joeyadams, 2 years ago)

Uses the "clock" package to print monotonic times

Line 
1import Control.Concurrent (threadDelay)
2import System.Posix.Clock
3
4main :: IO ()
5main = do
6    start <- getTime Monotonic
7    let loop n = do
8            t <- getTime Monotonic
9            putStrLn $ show n ++ ": " ++ show (sec t - sec start) ++ "s"
10            threadDelay 10000000
11            loop (n+1)
12     in loop (0 :: Integer)