diff options
Diffstat (limited to 'testsuite/tests/primops')
-rw-r--r-- | testsuite/tests/primops/should_run/T10678.hs | 22 | ||||
-rw-r--r-- | testsuite/tests/primops/should_run/all.T | 9 |
2 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/primops/should_run/T10678.hs b/testsuite/tests/primops/should_run/T10678.hs new file mode 100644 index 0000000000..9019ab6345 --- /dev/null +++ b/testsuite/tests/primops/should_run/T10678.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE MagicHash #-} + +import GHC.Prim + +main :: IO () +main = go 1000000# 10 (2^100) + +go :: Int# -> Integer -> Integer -> IO () +go 0# _ _ = return () +go n# a b = (a + b) `seq` go (n# -# 1#) a b +{-# NOINLINE go #-} + +{- +This test is based on a strategy from rwbarton relying on the inefficiency +of `Integer` addition as defined by `integer-gmp` without `runRW#`. + + When I was testing the patch interactively, I measured allocations for, + say, a million (large Integer) + (small Integer) additions. If that + addition allocates, say, 6 words, then one can fairly reliably write the + program so that it will allocate between 6 million and 7 million words, + total. +-} diff --git a/testsuite/tests/primops/should_run/all.T b/testsuite/tests/primops/should_run/all.T index b21279aa99..b0001d6d32 100644 --- a/testsuite/tests/primops/should_run/all.T +++ b/testsuite/tests/primops/should_run/all.T @@ -3,3 +3,12 @@ test('T7689', normal, compile_and_run, ['']) # The test is using unboxed tuples, so omit ghci test('T9430', omit_ways(['ghci']), compile_and_run, ['']) test('T10481', exit_code(1), compile_and_run, ['']) +test('T10678', + [stats_num_field('bytes allocated', + [(wordsize(64), 88041768, 5) + # 2015-11-04: 88041768 +/- 5% (before runRW#) + # 2015-11-04: 64004171 (after runRW#) + ]), + only_ways('normal') + ], + compile_and_run, ['-O']) |