Repository : ssh://darcs.haskell.org//srv/darcs/testsuite On branch : master
http://hackage.haskell.org/trac/ghc/changeset/87495227dfa630173bf503ad393439ac7a3d0da3 >--------------------------------------------------------------- commit 87495227dfa630173bf503ad393439ac7a3d0da3 Author: Ian Lynagh <[email protected]> Date: Sun Apr 17 13:34:31 2011 +0100 Add a performance test for #2762 >--------------------------------------------------------------- tests/ghc-regress/perf/space_leaks/T2762.hs | 18 ++++++++++++++++++ tests/ghc-regress/perf/space_leaks/T2762A.hs | 15 +++++++++++++++ tests/ghc-regress/perf/space_leaks/all.T | 8 ++++++++ 3 files changed, 41 insertions(+), 0 deletions(-) diff --git a/tests/ghc-regress/perf/space_leaks/T2762.hs b/tests/ghc-regress/perf/space_leaks/T2762.hs new file mode 100644 index 0000000..76ab045 --- /dev/null +++ b/tests/ghc-regress/perf/space_leaks/T2762.hs @@ -0,0 +1,18 @@ + +module Main (main) where + +import T2762A + +main :: IO () +main = do + let content1 = concat (replicate 1000000 "1x") ++ "0" + let i1 = fst $ input content1 + view i1 + + let content2 = concat (replicate 1000001 "1y") ++ "0" + let i2 = fst $ input content2 + view i2 + +view :: [Char] -> IO () +view [] = return () +view (i : is) = i `seq` view is diff --git a/tests/ghc-regress/perf/space_leaks/T2762A.hs b/tests/ghc-regress/perf/space_leaks/T2762A.hs new file mode 100644 index 0000000..665fa6e --- /dev/null +++ b/tests/ghc-regress/perf/space_leaks/T2762A.hs @@ -0,0 +1,15 @@ + +module T2762A (input) where + +class InputOutput a where + input :: String -> (a, String) + +instance InputOutput Char where + input (x : bs) = (x, bs) + +instance InputOutput a => InputOutput [a] where + input ('0':bs) = ([], bs) + input ('1':bs) = case input bs of + (x, bs') -> + case input bs' of + ~(xs, bs'') -> (x : xs, bs'') diff --git a/tests/ghc-regress/perf/space_leaks/all.T b/tests/ghc-regress/perf/space_leaks/all.T index 7be1aaa..809ec01 100644 --- a/tests/ghc-regress/perf/space_leaks/all.T +++ b/tests/ghc-regress/perf/space_leaks/all.T @@ -29,3 +29,11 @@ test('T4334', omit_ways(['profasm','profthreaded']) ], compile_and_run, ['']) + +test('T2762', + [# peak_megabytes_allocated is 2 with 7.0.2. + # Was 57 with 6.12.3. + stats_num_field('peak_megabytes_allocated', 1, 3), + only_ways(['normal']), + extra_clean(['T2762A.hi', 'T2762A.o'])], + compile_and_run, ['-O']) _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
