Repository : ssh://darcs.haskell.org//srv/darcs/packages/base

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/3fe743c59741ae4d8ed6e353b78e370c4eb82e05

>---------------------------------------------------------------

commit 3fe743c59741ae4d8ed6e353b78e370c4eb82e05
Author: Ian Lynagh <[email protected]>
Date:   Sat Nov 19 21:36:10 2011 +0000

    Move CPUTime001 here from testsuite/tests/lib/CPUTime

>---------------------------------------------------------------

 tests/CPUTime001.hs     |   26 ++++++++++++++++++++++++++
 tests/CPUTime001.stdout |    4 ++++
 tests/all.T             |    1 +
 3 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/tests/CPUTime001.hs b/tests/CPUTime001.hs
new file mode 100644
index 0000000..6c43c57
--- /dev/null
+++ b/tests/CPUTime001.hs
@@ -0,0 +1,26 @@
+-- !!! 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)
diff --git a/tests/CPUTime001.stdout b/tests/CPUTime001.stdout
new file mode 100644
index 0000000..032e759
--- /dev/null
+++ b/tests/CPUTime001.stdout
@@ -0,0 +1,4 @@
+1028457
+1664079
+2692537
+(True,True)
diff --git a/tests/all.T b/tests/all.T
index 7c9fc6e..a55ad83 100644
--- a/tests/all.T
+++ b/tests/all.T
@@ -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, [''])



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to