diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2015-11-12 14:52:11 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-11-12 14:52:13 +0100 |
commit | 351de169e14ad9277aaca653df4a3753c151f7bb (patch) | |
tree | db78ed4b832e6063abe9832ecb8d5e4f4bb8378b /testsuite/tests/primops | |
parent | 8755719462733dee52190e298436e8e8e8f12bea (diff) | |
download | haskell-351de169e14ad9277aaca653df4a3753c151f7bb.tar.gz |
New magic function for applying realWorld#
Test Plan: validate
Reviewers: goldfire, erikd, rwbarton, simonpj, austin, simonmar, hvr
Reviewed By: simonpj
Subscribers: simonmar, thomie
Differential Revision: https://phabricator.haskell.org/D1103
GHC Trac Issues: #10678
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']) |