From d793a148917aa62e8860ffd7b66936d41bfa5737 Mon Sep 17 00:00:00 2001
From: Johan Tibell <johan.tibell@gmail.com>
Date: Tue, 11 Mar 2014 22:39:00 +0100
Subject: [PATCH] Add perf test for inline array allocation

---
 .../tests/perf/should_run/InlineArrayAlloc.hs    | 16 ++++++++++++++++
 testsuite/tests/perf/should_run/all.T            |  6 ++++++
 2 files changed, 22 insertions(+)
 create mode 100644 testsuite/tests/perf/should_run/InlineArrayAlloc.hs

diff --git a/testsuite/tests/perf/should_run/InlineArrayAlloc.hs b/testsuite/tests/perf/should_run/InlineArrayAlloc.hs
new file mode 100644
index 000000000000..09f3e405864f
--- /dev/null
+++ b/testsuite/tests/perf/should_run/InlineArrayAlloc.hs
@@ -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', () #)
diff --git a/testsuite/tests/perf/should_run/all.T b/testsuite/tests/perf/should_run/all.T
index 9ce4d45e51a3..ea1ba8f59ec7 100644
--- a/testsuite/tests/perf/should_run/all.T
+++ b/testsuite/tests/perf/should_run/all.T
@@ -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'])
-- 
GitLab