Repository : ssh://darcs.haskell.org//srv/darcs/testsuite

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/a0f1542eadf114f9e853be8e8c1c7fc1894c1412

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

commit a0f1542eadf114f9e853be8e8c1c7fc1894c1412
Author: Simon Peyton Jones <[email protected]>
Date:   Fri Oct 21 18:07:52 2011 +0100

    Test Trac #5549

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

 tests/perf/should_run/T5549.hs     |   27 +++++++++++++++++++++++++++
 tests/perf/should_run/T5549.stdout |    2 ++
 tests/perf/should_run/all.T        |   14 ++++++++++++++
 3 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/tests/perf/should_run/T5549.hs b/tests/perf/should_run/T5549.hs
new file mode 100644
index 0000000..cab0dc0
--- /dev/null
+++ b/tests/perf/should_run/T5549.hs
@@ -0,0 +1,27 @@
+module Main where
+-- See Trac #5549
+-- The issue here is allocating integer constants inside a loop
+
+
+lcs3 :: Eq a => [a] -> [a] -> [a]
+lcs3 a b = fst $ aux (a, length a) (b, length b)
+  where
+    aux (_,0) _ = ([],0)
+    aux _ (_,0) = ([],0)
+    aux (a@(ha:as),la) (b@(hb:bs), lb)
+      | ha == hb  = let (s,n) = aux (as,la-1) (bs,lb-1) in (ha : s, n+1)
+      | otherwise =
+        let (sa,na) = aux (as,la-1) (b,lb)
+            (sb,nb) = aux (a,la) (bs,lb-1) in
+        if na > nb then (sa,na) else (sb,nb)
+
+f :: Integer -> Integer -> Integer
+f acc 0 = acc
+f acc n = g (acc + 1) (n-1)
+
+g :: Integer -> Integer -> Integer
+g acc 0 = acc
+g acc n = f (acc -1) (n-1)
+
+main = do putStrLn . show $ f 0 100000000
+          putStrLn . show $ lcs3 [1..20] [10..20]
diff --git a/tests/perf/should_run/T5549.stdout 
b/tests/perf/should_run/T5549.stdout
new file mode 100644
index 0000000..95a4feb
--- /dev/null
+++ b/tests/perf/should_run/T5549.stdout
@@ -0,0 +1,2 @@
+0
+[10,11,12,13,14,15,16,17,18,19,20]
diff --git a/tests/perf/should_run/all.T b/tests/perf/should_run/all.T
index b3c3b6a..af06fad 100644
--- a/tests/perf/should_run/all.T
+++ b/tests/perf/should_run/all.T
@@ -150,3 +150,17 @@ test('T5205',
      compile_and_run,
      ['-O'])
 
+test('T5549',
+     [if_wordsize(32,
+          stats_num_field('bytes allocated', 5000000000,
+                                             8000000000)),
+                           # expected value: 47088 (x86/Darwin)
+      if_wordsize(64,
+          stats_num_field('bytes allocated', 5000000000,
+                                             8000000000)),
+                           # expected value: 6,725,846,120 (amd64/Linux)
+      only_ways(['normal'])
+      ],
+     compile_and_run,
+     ['-O'])
+



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

Reply via email to