[commit: testsuite] master: Test Trac #5113 (435ddb7)

Simon Peyton Jones simonpj at microsoft.com
Thu Apr 21 15:36:11 CEST 2011


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

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/435ddb71ab266e3932b53c4fe81a977f92128874

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

commit 435ddb71ab266e3932b53c4fe81a977f92128874
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Apr 21 14:35:14 2011 +0100

    Test Trac #5113

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

 tests/ghc-regress/perf/should_run/T5113.hs         |   31 ++++++++++++++++++++
 .../3279.stdout => perf/should_run/T5113.stdout}   |    0 
 tests/ghc-regress/perf/should_run/all.T            |    8 +++++
 3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/tests/ghc-regress/perf/should_run/T5113.hs b/tests/ghc-regress/perf/should_run/T5113.hs
new file mode 100644
index 0000000..e87bcb6
--- /dev/null
+++ b/tests/ghc-regress/perf/should_run/T5113.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE BangPatterns #-}
+module Main where
+
+import Data.Array.Base (unsafeRead, unsafeWrite)
+import Data.Array.ST
+import Data.Array.Unboxed
+import Control.Monad.ST
+
+main = print (divisorCounts 1000000 ! 342)
+
+isqrt :: Int -> Int
+isqrt n = floor (sqrt $ fromIntegral n)
+
+divisorCounts :: Int -> UArray Int Int
+divisorCounts n = runSTUArray $ do
+    let !rt = isqrt n
+    darr <- newArray (0,n) 1 :: ST s (STUArray s Int Int)
+    let inc i = unsafeRead darr i >>= \k -> unsafeWrite darr i (k+1)
+        note step i
+            | i > n     = return ()
+            | otherwise = do
+                inc i
+                note step (i+step)
+        count j
+            | j > rt    = return ()
+            | otherwise = do
+                note (2*j) (j*j)
+                count (j+2)
+    note 2 4
+    count 3
+    return darr
diff --git a/tests/ghc-regress/concurrent/should_run/3279.stdout b/tests/ghc-regress/perf/should_run/T5113.stdout
similarity index 100%
copy from tests/ghc-regress/concurrent/should_run/3279.stdout
copy to tests/ghc-regress/perf/should_run/T5113.stdout
diff --git a/tests/ghc-regress/perf/should_run/all.T b/tests/ghc-regress/perf/should_run/all.T
index f1d918d..23ec452 100644
--- a/tests/ghc-regress/perf/should_run/all.T
+++ b/tests/ghc-regress/perf/should_run/all.T
@@ -107,3 +107,11 @@ test('T149',
      run_command,
      ['$MAKE -s --no-print-directory T149'])
 
+test('T5113',
+     [stats_num_field('bytes allocated', 8000000,
+                                         9000000),
+      only_ways(['normal'])
+      ],
+     compile_and_run,
+     ['-O'])
+





More information about the Cvs-ghc mailing list