Commit 4c1bca1b authored by Ian Lynagh's avatar Ian Lynagh

Replace simplrun006 with a less fragile perf test T149

parent 67b2af08
......@@ -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"
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
......@@ -8,30 +8,12 @@ module Main (main) where
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!"
main :: IO ()
main = print $ playerMostOccur2 [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
playerMostOccur2 :: [Int] -> Int
playerMostOccur2 [a] = a
playerMostOccur2 (x:xs)
......
......@@ -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'])
......@@ -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, [''])
......
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