Commit 31159cb7 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Move CPUTime001 here from testsuite/tests/lib/CPUTime

parent 8019a642
-- !!! Test getCPUTime
import System.CPUTime
import System.IO
main :: IO ()
main = do
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
| n <= 1 = 1
| otherwise = (n1 + n2 + 1)
where
n1 = nfib (n-1)
n2 = nfib (n-2)
1028457
1664079
2692537
(True,True)
......@@ -6,3 +6,4 @@ test('tempfiles', normal, compile_and_run, [''])
test('fixed', normal, compile_and_run, [''])
test('quotOverflow', normal, compile_and_run, [''])
test('assert', exit_code(1), compile_and_run, ['-fno-ignore-asserts'])
test('CPUTime001', normal, compile_and_run, [''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment