diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-17 22:00:26 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-17 22:00:26 +0100 |
commit | ad0427d4c31856c4f0fe57c1ed6cf7b4fec1ab6e (patch) | |
tree | 273c25cfc1914ccfd17158e2e492d29b56ea0859 /test | |
parent | c88325920b2000584bf9efc344f2a71ad066f4a4 (diff) |
work on performance comparison tool
Diffstat (limited to 'test')
-rw-r--r-- | test/PerfReport.hs | 34 | ||||
-rw-r--r-- | test/runTests.hs | 14 |
2 files changed, 43 insertions, 5 deletions
diff --git a/test/PerfReport.hs b/test/PerfReport.hs new file mode 100644 index 00000000..7ad0b9b8 --- /dev/null +++ b/test/PerfReport.hs | |||
@@ -0,0 +1,34 @@ | |||
1 | {-# LANGUAGE ViewPatterns, TupleSections #-} | ||
2 | import Data.Char | ||
3 | import System.Directory | ||
4 | import System.FilePath | ||
5 | import Text.Printf | ||
6 | import Control.Monad | ||
7 | import Data.Map (Map,(!)) | ||
8 | import qualified Data.Map as Map | ||
9 | |||
10 | -- HINT: lambdacube-compiler-test-suite --overall-time performance +RTS -tcurrent.log --machine-readable | ||
11 | -- output: current.log overall-time.txt | ||
12 | |||
13 | resultPath = "performance" | ||
14 | |||
15 | main = do | ||
16 | -- read current result | ||
17 | overallTime <- read <$> readFile "overall-time.txt" :: IO Double | ||
18 | let toDouble = read :: String -> Double | ||
19 | toInteger = read :: String -> Integer | ||
20 | new <- Map.fromList . (:) ("overall_time",show overallTime) . read . unlines . tail . lines <$> readFile "current.log" :: IO (Map String String) | ||
21 | let totalAlloc a = toInteger $ a ! "bytes allocated" | ||
22 | peakAlloc a = toInteger $ a ! "peak_megabytes_allocated" | ||
23 | totalAllocF a = toDouble $ a ! "bytes allocated" | ||
24 | peakAllocF a = toDouble $ a ! "peak_megabytes_allocated" | ||
25 | overallTime a = toDouble $ a ! "overall_time" | ||
26 | |||
27 | putStrLn $ printf "%-20s time: % 6.3fs \tpeak mem: % 6d MBytes total alloc: %d bytes" "current" (overallTime new) (peakAlloc new) (totalAlloc new) | ||
28 | -- read previous results | ||
29 | perfs <- filter ((".perf" ==) . takeExtension) <$> getDirectoryContents "performance" >>= mapM (\n -> (n,) . read <$> readFile (resultPath </> n)) :: IO [(String,Map String String)] | ||
30 | forM_ perfs $ \(name,old) -> do | ||
31 | putStrLn $ printf "%-20s time: %+6.3f%% \tpeak mem: %+6.3f%% \ttotal alloc: %+6.3f%%" | ||
32 | name (100*(overallTime new / overallTime old - 1)) (100*(peakAllocF new / peakAllocF old - 1)) (100*(totalAllocF new / totalAllocF old - 1)) | ||
33 | --TODO | ||
34 | --writeFile "performance/release-0.5.perf" $ show new \ No newline at end of file | ||
diff --git a/test/runTests.hs b/test/runTests.hs index c36e6c59..a175bc7e 100644 --- a/test/runTests.hs +++ b/test/runTests.hs | |||
@@ -84,10 +84,11 @@ testDataPath = "./testdata" | |||
84 | 84 | ||
85 | data Config | 85 | data Config |
86 | = Config | 86 | = Config |
87 | { cfgVerbose :: Bool | 87 | { cfgVerbose :: Bool |
88 | , cfgReject :: Bool | 88 | , cfgReject :: Bool |
89 | , cfgTimeout :: NominalDiffTime | 89 | , cfgTimeout :: NominalDiffTime |
90 | , cfgIgnore :: [String] | 90 | , cfgIgnore :: [String] |
91 | , cfgOverallTime :: Bool | ||
91 | } deriving Show | 92 | } deriving Show |
92 | 93 | ||
93 | arguments :: Parser (Config, [String]) | 94 | arguments :: Parser (Config, [String]) |
@@ -96,6 +97,7 @@ arguments = | |||
96 | <*> switch (short 'r' <> long "reject" <> help "Reject test cases with missing, new or different .out files") | 97 | <*> switch (short 'r' <> long "reject" <> help "Reject test cases with missing, new or different .out files") |
97 | <*> option (realToFrac <$> (auto :: ReadM Double)) (value 60 <> short 't' <> long "timeout" <> help "Timeout for tests in seconds") | 98 | <*> option (realToFrac <$> (auto :: ReadM Double)) (value 60 <> short 't' <> long "timeout" <> help "Timeout for tests in seconds") |
98 | <*> many (option (eitherReader Right) (short 'i' <> long "ignore" <> help "Ignore test")) | 99 | <*> many (option (eitherReader Right) (short 'i' <> long "ignore" <> help "Ignore test")) |
100 | <*> switch (long "overall-time" <> help "Writes overall time to overall-time.txt") | ||
99 | ) | 101 | ) |
100 | <*> many (strArgument idm) | 102 | <*> many (strArgument idm) |
101 | 103 | ||
@@ -167,7 +169,9 @@ main = do | |||
167 | ] | 169 | ] |
168 | ++ sh (\s ty -> ty == Passed && isWip s) "wip passed test" | 170 | ++ sh (\s ty -> ty == Passed && isWip s) "wip passed test" |
169 | 171 | ||
170 | putStrLn $ "Overall time: " ++ showTime (sum $ map fst resultDiffs) | 172 | let overallTime = sum $ map fst resultDiffs |
173 | putStrLn $ "Overall time: " ++ showTime overallTime | ||
174 | when cfgOverallTime $ writeFile "overall-time.txt" $ show (realToFrac overallTime :: Double) | ||
171 | 175 | ||
172 | when (or [erroneous r | ((_, r), f) <- zip resultDiffs testSet, not $ isWip f]) exitFailure | 176 | when (or [erroneous r | ((_, r), f) <- zip resultDiffs testSet, not $ isWip f]) exitFailure |
173 | putStrLn "All OK" | 177 | putStrLn "All OK" |