Typo
[packages/base.git] / tests / CPUTime001.hs
1 -- !!! Test getCPUTime
2
3 import System.CPUTime
4 import System.IO
5
6 main :: IO ()
7 main = do
8 t28 <- timeFib 28
9 t29 <- timeFib 29
10 t30 <- timeFib 30
11 print (t28 <= t29, t29 <= t30)
12
13 timeFib :: Integer -> IO Integer
14 timeFib n = do
15 start <- getCPUTime
16 print (nfib n)
17 end <- getCPUTime
18 return (end - start)
19
20 nfib :: Integer -> Integer
21 nfib n
22 | n <= 1 = 1
23 | otherwise = (n1 + n2 + 1)
24 where
25 n1 = nfib (n-1)
26 n2 = nfib (n-2)