[project @ 2001-04-02 21:10:04 by panne]
authorpanne <unknown>
Mon, 2 Apr 2001 21:10:04 +0000 (21:10 +0000)
committerpanne <unknown>
Mon, 2 Apr 2001 21:10:04 +0000 (21:10 +0000)
Made this test a little bit less fragile (my 1GHz Athlon was too fast
for the expected output :-)

ghc/tests/io/should_run/io012.hs
ghc/tests/io/should_run/io012.stdout

index 3ebf203..807bbb7 100644 (file)
@@ -1,14 +1,21 @@
 -- !!! Test getCPUTime
 
 import IO
-
 import CPUTime
 
+main :: IO ()
 main = do
-    t <- getCPUTime
-    print (nfib 30)
-    t <- getCPUTime
-    print (length (show t)) -- printing the CPU time itself is un-cool if you want to diff the output..
+    t28 <- timeFib 28
+    t29 <- timeFib 29
+    t30 <- timeFib 30
+    print (t28 <= t29, t29 <= t30)
+
+timeFib :: Integer -> IO Integer
+timeFib n = do
+    start <- getCPUTime
+    print (nfib n)
+    end <- getCPUTime
+    return (end - start)
 
 nfib :: Integer -> Integer
 nfib n