[commit: testsuite] master: Add a perf test for #7257 (ae076b7)

Simon Marlow <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/testsuite

On branch  : master

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

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

commit ae076b7a7de67539e0ef8fdf0b05955c5d2116b1
Author: Simon Marlow <[email protected]>
Date:   Fri Sep 21 14:31:01 2012 +0100

    Add a perf test for #7257

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

 tests/perf/should_run/T7257.hs                     |   30 ++++++++++++++++++++
 .../ann01.stderr => perf/should_run/T7257.stdout}  |    0 
 tests/perf/should_run/all.T                        |   17 +++++++++++
 3 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/tests/perf/should_run/T7257.hs b/tests/perf/should_run/T7257.hs
new file mode 100644
index 0000000..ef65db3
--- /dev/null
+++ b/tests/perf/should_run/T7257.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE BangPatterns #-}
+module Main where
+
+import qualified Data.ByteString as S
+import Data.IORef
+import Control.Monad
+
+makeBs :: Int -> S.ByteString
+makeBs n = S.replicate n (fromIntegral n)
+
+doStuff :: IORef [S.ByteString] -> Int -> IO ()
+doStuff ref n = do
+    let !bs = makeBs n
+    modifyIORef ref (bs:)
+{-# NOINLINE doStuff #-}
+
+undo :: IORef [S.ByteString] -> IO ()
+undo ref = do
+    h <- atomicModifyIORef ref (\(x:xs) -> (xs,x))
+    S.length h `seq` return ()
+
+main = do
+    ref <- newIORef [S.empty]
+    let fn n = do
+        doStuff ref n
+        when (rem 5 n /= 0 ) $ undo ref
+        
+    mapM_ fn (take 5000000 $ cycle [1..100])
+    var <- readIORef ref
+    print $ length var
diff --git a/tests/annotations/should_compile/ann01.stderr b/tests/perf/should_run/T7257.stdout
similarity index 100%
copy from tests/annotations/should_compile/ann01.stderr
copy to tests/perf/should_run/T7257.stdout
diff --git a/tests/perf/should_run/all.T b/tests/perf/should_run/all.T
index c7582d6..22acf28 100644
--- a/tests/perf/should_run/all.T
+++ b/tests/perf/should_run/all.T
@@ -237,3 +237,20 @@ test('T5536',
     compile_and_run,
     ['-O'])
 
+test('T7257',
+     [if_wordsize(32,
+          stats_range_field('bytes allocated', 1150000000, 10)),
+                           # expected value: 1246287228 (i386/Linux)
+      if_wordsize(32,
+          stats_range_field('peak_megabytes_allocated', 150, 5)),
+                           # unkonwn
+      if_wordsize(64,
+          stats_range_field('bytes allocated', 1774893760, 5)),
+                           # 2012-09-21: 1774893760 (amd64/Linux)
+      if_wordsize(64,
+          stats_range_field('peak_megabytes_allocated', 227, 5)),
+                           # 2012-09-21: 227 (amd64/Linux)
+
+      only_ways(['normal'])
+     ],
+    compile_and_run, ['-O'])
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.