Add perf test for inline array allocation
authorJohan Tibell <johan.tibell@gmail.com>
Tue, 11 Mar 2014 21:39:00 +0000 (22:39 +0100)
committerJohan Tibell <johan.tibell@gmail.com>
Tue, 11 Mar 2014 21:39:00 +0000 (22:39 +0100)
testsuite/tests/perf/should_run/InlineArrayAlloc.hs [new file with mode: 0644]
testsuite/tests/perf/should_run/all.T

diff --git a/testsuite/tests/perf/should_run/InlineArrayAlloc.hs b/testsuite/tests/perf/should_run/InlineArrayAlloc.hs
new file mode 100644 (file)
index 0000000..09f3e40
--- /dev/null
@@ -0,0 +1,16 @@
+{-# LANGUAGE BangPatterns, MagicHash, UnboxedTuples #-}
+module Main where
+
+import GHC.Exts
+import GHC.IO
+
+main :: IO ()
+main = loop 10000000
+  where
+    loop :: Int -> IO ()
+    loop 0 = return ()
+    loop i = newArray >> loop (i-1)
+
+newArray :: IO ()
+newArray = IO $ \s -> case newArray# 16# () s of
+    (# s', _ #) -> (# s', () #)
index 9ce4d45..ea1ba8f 100644 (file)
@@ -331,3 +331,9 @@ test('T7619',
      compile_and_run,
      ['-O'])
 
+test('InlineArrayAlloc',
+     [stats_num_field('bytes allocated',
+                      [ (wordsize(64), 1600040960, 5)]),
+      only_ways(['normal'])],
+     compile_and_run,
+     ['-O2'])