From 29720df7c11237a87ed20f19928c43df3db4e979 Mon Sep 17 00:00:00 2001 From: Ian Lynagh <igloo@earth.li> Date: Sun, 17 Apr 2011 18:14:48 +0100 Subject: [PATCH] Replace simplrun006 with a less fragile perf test T149 --- tests/ghc-regress/perf/should_run/Makefile | 10 ++++- tests/ghc-regress/perf/should_run/T149_A.hs | 25 +++++++++++ tests/ghc-regress/perf/should_run/T149_B.hs | 26 +++++++++++ tests/ghc-regress/perf/should_run/all.T | 22 ++++++---- tests/ghc-regress/simplCore/should_run/all.T | 3 -- .../simplCore/should_run/simplrun006.hs | 44 ------------------- .../simplCore/should_run/simplrun006.stdout | 6 --- 7 files changed, 74 insertions(+), 62 deletions(-) create mode 100644 tests/ghc-regress/perf/should_run/T149_A.hs create mode 100644 tests/ghc-regress/perf/should_run/T149_B.hs delete mode 100644 tests/ghc-regress/simplCore/should_run/simplrun006.hs delete mode 100644 tests/ghc-regress/simplCore/should_run/simplrun006.stdout diff --git a/tests/ghc-regress/perf/should_run/Makefile b/tests/ghc-regress/perf/should_run/Makefile index f40e014dc..3e0bdb1f7 100644 --- a/tests/ghc-regress/perf/should_run/Makefile +++ b/tests/ghc-regress/perf/should_run/Makefile @@ -24,5 +24,13 @@ T2902: $(RM) -f T2902_A_PairingSum.o T2902_B_PairingSum.o T2902_Sum.o '$(TEST_HC)' -v0 -O --make T2902_A -rtsopts '$(TEST_HC)' -v0 -O --make T2902_B -rtsopts - BAA=`./T2902_A +RTS -t --machine-readable 2>&1 | grep '"bytes allocated"' | sed -e 's/.*, "//' -e 's/")//'`; BAB=`./T2902_B +RTS -t --machine-readable 2>&1 | grep '"bytes allocated"' | sed -e 's/.*, "//' -e 's/")//'`; [ "$$BAA" = "" ] && echo 'T2902_A: No "bytes allocated"'; [ "$$BAA" = "$$BAB" ] || echo 'T2902: Mismatch in "bytes allocated"' + BAA=`./T2902_A +RTS -t --machine-readable 2>&1 | grep '"bytes allocated"' | sed -e 's/.*, "//' -e 's/")//'`; BAB=`./T2902_B +RTS -t --machine-readable 2>&1 | grep '"bytes allocated"' | sed -e 's/.*, "//' -e 's/")//'`; [ "$$BAA" = "" ] && echo 'T2902_A: No "bytes allocated"'; [ "$$BAA" = "$$BAB" ] || echo "T2902: Mismatch in \"bytes allocated\": $$BAA $$BAB" + +.PHONY: T149 +T149: + $(RM) -f T149_A T149_A.hi T149_A.o + $(RM) -f T149_B T149_B.hi T149_B.o + '$(TEST_HC)' -v0 -O --make T149_A -rtsopts + '$(TEST_HC)' -v0 -O --make T149_B -rtsopts + BAA=`./T149_A +RTS -t --machine-readable 2>&1 | grep '"bytes allocated"' | sed -e 's/.*, "//' -e 's/")//'`; BAB=`./T149_B +RTS -t --machine-readable 2>&1 | grep '"bytes allocated"' | sed -e 's/.*, "//' -e 's/")//'`; [ "$$BAA" = "" ] && echo 'T149_A: No "bytes allocated"'; [ "$$BAA" = "$$BAB" ] || echo "T149: Mismatch in \"bytes allocated\": $$BAA $$BAB" diff --git a/tests/ghc-regress/perf/should_run/T149_A.hs b/tests/ghc-regress/perf/should_run/T149_A.hs new file mode 100644 index 000000000..dd745460c --- /dev/null +++ b/tests/ghc-regress/perf/should_run/T149_A.hs @@ -0,0 +1,25 @@ +module Main (main) where + +-- See Trac #149 + +-- Curently (with GHC 7.0) the CSE works, just, +-- but it's delicate. + + +import System.CPUTime + +main :: IO () +main = print $ playerMostOccur1 [1..m] + +m :: Int +m = 22 + +playerMostOccur1 :: [Int] -> Int +playerMostOccur1 [a] = a +playerMostOccur1 (x:xs) + | numOccur x (x:xs) > numOccur (playerMostOccur1 xs) xs = x + | otherwise = playerMostOccur1 xs + +numOccur :: Int -> [Int] -> Int +numOccur i is = length $ filter (i ==) is + diff --git a/tests/ghc-regress/perf/should_run/T149_B.hs b/tests/ghc-regress/perf/should_run/T149_B.hs new file mode 100644 index 000000000..fcc87cdf5 --- /dev/null +++ b/tests/ghc-regress/perf/should_run/T149_B.hs @@ -0,0 +1,26 @@ +module Main (main) where + +-- See Trac #149 + +-- Curently (with GHC 7.0) the CSE works, just, +-- but it's delicate. + + +import System.CPUTime + +main :: IO () +main = print $ playerMostOccur2 [1..m] + +m :: Int +m = 22 + +playerMostOccur2 :: [Int] -> Int +playerMostOccur2 [a] = a +playerMostOccur2 (x:xs) + | numOccur x (x:xs) > numOccur pmo xs = x + | otherwise = pmo + where pmo = playerMostOccur2 xs + +numOccur :: Int -> [Int] -> Int +numOccur i is = length $ filter (i ==) is + diff --git a/tests/ghc-regress/perf/should_run/all.T b/tests/ghc-regress/perf/should_run/all.T index 1886d433d..f1d918d89 100644 --- a/tests/ghc-regress/perf/should_run/all.T +++ b/tests/ghc-regress/perf/should_run/all.T @@ -90,14 +90,20 @@ test('MethSharing', compile_and_run, ['-O']) test('T2902', - [normal, - extra_clean(['T2902_A', 'T2902_B', - 'T2902_A.hi', 'T2902_B.hi', - 'T2902_A.o', 'T2902_B.o', - 'T2902_A_PairingSum.hi', 'T2902_B_PairingSum.hi', - 'T2902_A_PairingSum.o', 'T2902_B_PairingSum.o', - 'T2902_Sum.hi', - 'T2902_Sum.o'])], + extra_clean(['T2902_A', 'T2902_B', + 'T2902_A.hi', 'T2902_B.hi', + 'T2902_A.o', 'T2902_B.o', + 'T2902_A_PairingSum.hi', 'T2902_B_PairingSum.hi', + 'T2902_A_PairingSum.o', 'T2902_B_PairingSum.o', + 'T2902_Sum.hi', + 'T2902_Sum.o']), run_command, ['$MAKE -s --no-print-directory T2902']) +test('T149', + [expect_broken(149), + extra_clean(['T149_A', 'T149_B', + 'T149_A.hi', 'T149_B.hi', + 'T149_A.o', 'T149_B.o'])], + run_command, + ['$MAKE -s --no-print-directory T149']) diff --git a/tests/ghc-regress/simplCore/should_run/all.T b/tests/ghc-regress/simplCore/should_run/all.T index 82b1c5924..a4a2e6c40 100644 --- a/tests/ghc-regress/simplCore/should_run/all.T +++ b/tests/ghc-regress/simplCore/should_run/all.T @@ -15,9 +15,6 @@ test('simplrun003', normal, compile_and_run, ['']) test('simplrun004', normal, compile_and_run, ['']) test('simplrun005', normal, compile_and_run, ['']) -test('simplrun006', expect_fail, compile_and_run, ['']) - # This is a CSE test - test('simplrun007', normal, compile_and_run, ['']) test('simplrun008', normal, compile_and_run, ['']) test('simplrun009', normal, compile_and_run, ['']) diff --git a/tests/ghc-regress/simplCore/should_run/simplrun006.hs b/tests/ghc-regress/simplCore/should_run/simplrun006.hs deleted file mode 100644 index 0e43e9ce0..000000000 --- a/tests/ghc-regress/simplCore/should_run/simplrun006.hs +++ /dev/null @@ -1,44 +0,0 @@ -module Main (main) where - --- See Trac #149 - --- Curently (with GHC 7.0) the CSE works, just, --- but it's delicate. - - -import System.CPUTime - -main = do start <- getCPUTime - putStrLn "Start" - print $ playerMostOccur1 [1..m] - middle <- getCPUTime - putStrLn "Middle" - print $ playerMostOccur2 [1..m] - end <- getCPUTime - putStrLn "End" - let d1 = middle - start - d2 = end - middle - if d1 > 2 * d2 - then do print d1 - print d2 - else putStrLn "OK!" - -m :: Int -m = 22 - -playerMostOccur1 :: [Int] -> Int -playerMostOccur1 [a] = a -playerMostOccur1 (x:xs) - | numOccur x (x:xs) > numOccur (playerMostOccur1 xs) xs = x - | otherwise = playerMostOccur1 xs - -playerMostOccur2 :: [Int] -> Int -playerMostOccur2 [a] = a -playerMostOccur2 (x:xs) - | numOccur x (x:xs) > numOccur pmo xs = x - | otherwise = pmo - where pmo = playerMostOccur2 xs - -numOccur :: Int -> [Int] -> Int -numOccur i is = length $ filter (i ==) is - diff --git a/tests/ghc-regress/simplCore/should_run/simplrun006.stdout b/tests/ghc-regress/simplCore/should_run/simplrun006.stdout deleted file mode 100644 index 81857ee52..000000000 --- a/tests/ghc-regress/simplCore/should_run/simplrun006.stdout +++ /dev/null @@ -1,6 +0,0 @@ -Start -22 -Middle -22 -End -OK! -- GitLab