Commit faec924a authored by Simon Marlow's avatar Simon Marlow

Add a perf test for #7257

parent 7ba13fa3
{-# LANGUAGE BangPatterns #-}
module Main where
import qualified Data.ByteString as S
import Data.IORef
import Control.Monad
makeBs :: Int -> S.ByteString
makeBs n = S.replicate n (fromIntegral n)
doStuff :: IORef [S.ByteString] -> Int -> IO ()
doStuff ref n = do
let !bs = makeBs n
modifyIORef ref (bs:)
{-# NOINLINE doStuff #-}
undo :: IORef [S.ByteString] -> IO ()
undo ref = do
h <- atomicModifyIORef ref (\(x:xs) -> (xs,x))
S.length h `seq` return ()
main = do
ref <- newIORef [S.empty]
let fn n = do
doStuff ref n
when (rem 5 n /= 0 ) $ undo ref
mapM_ fn (take 5000000 $ cycle [1..100])
var <- readIORef ref
print $ length var
......@@ -237,3 +237,20 @@ test('T5536',
compile_and_run,
['-O'])
test('T7257',
[if_wordsize(32,
stats_range_field('bytes allocated', 1150000000, 10)),
# expected value: 1246287228 (i386/Linux)
if_wordsize(32,
stats_range_field('peak_megabytes_allocated', 150, 5)),
# unkonwn
if_wordsize(64,
stats_range_field('bytes allocated', 1774893760, 5)),
# 2012-09-21: 1774893760 (amd64/Linux)
if_wordsize(64,
stats_range_field('peak_megabytes_allocated', 227, 5)),
# 2012-09-21: 227 (amd64/Linux)
only_ways(['normal'])
],
compile_and_run, ['-O'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment