blob: 9019ab6345e8439d464385d389aaefa462c589ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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.
-}
|