diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-18 10:56:24 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-18 10:56:24 +0100 |
commit | 5f7bbe131b0645a74a0389172ab302e2b25ea9c7 (patch) | |
tree | 3e7b1bb946a9980e8b2f3b54e64489f9575c82b7 /test | |
parent | 4d920b114dd6712a7465e0c48e96440c9913ca72 (diff) |
update todo
Diffstat (limited to 'test')
-rw-r--r-- | test/PerfReport.hs | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/test/PerfReport.hs b/test/PerfReport.hs index 17cbb0af..9103a2a1 100644 --- a/test/PerfReport.hs +++ b/test/PerfReport.hs | |||
@@ -1,18 +1,37 @@ | |||
1 | {-# LANGUAGE ViewPatterns, TupleSections #-} | 1 | {-# LANGUAGE ViewPatterns, TupleSections, RecordWildCards #-} |
2 | import Data.Char | 2 | import Data.Char |
3 | import System.Directory | 3 | import System.Directory |
4 | import System.FilePath | 4 | import System.FilePath |
5 | import Text.Printf | 5 | import Text.Printf |
6 | import Control.Monad | 6 | import Control.Monad |
7 | import Options.Applicative | ||
7 | import Data.Map (Map,(!)) | 8 | import Data.Map (Map,(!)) |
8 | import qualified Data.Map as Map | 9 | import qualified Data.Map as Map |
9 | 10 | ||
10 | -- HINT: lambdacube-compiler-test-suite --overall-time performance +RTS -tcurrent.log --machine-readable | 11 | -- HINT: lambdacube-compiler-test-suite --overall-time performance +RTS -tcurrent.log --machine-readable |
11 | -- output: current.log overall-time.txt | 12 | -- output: current.log overall-time.txt |
12 | 13 | ||
13 | resultPath = "performance" | 14 | data Config |
15 | = Config | ||
16 | { resultPath :: String | ||
17 | , output :: Maybe String | ||
18 | } | ||
14 | 19 | ||
15 | main = do | 20 | sample :: Parser Config |
21 | sample = Config | ||
22 | <$> pure "performance" | ||
23 | <*> optional (strOption (long "output" <> short 'o' <> metavar "FILENAME" <> help "output file name")) | ||
24 | |||
25 | main :: IO () | ||
26 | main = comparePerf =<< execParser opts | ||
27 | where | ||
28 | opts = info (helper <*> sample) | ||
29 | ( fullDesc | ||
30 | <> progDesc "compares LambdaCube 3D compiper performance" | ||
31 | <> header ("LambdaCube 3D compiler performance report")) | ||
32 | |||
33 | comparePerf :: Config -> IO () | ||
34 | comparePerf cfg@Config{..} = do | ||
16 | -- read current result | 35 | -- read current result |
17 | overallTime <- read <$> readFile "overall-time.txt" :: IO Double | 36 | overallTime <- read <$> readFile "overall-time.txt" :: IO Double |
18 | let toDouble = read :: String -> Double | 37 | let toDouble = read :: String -> Double |
@@ -30,5 +49,6 @@ main = do | |||
30 | forM_ perfs $ \(name,old) -> do | 49 | forM_ perfs $ \(name,old) -> do |
31 | putStrLn $ printf "%-20s time: %+6.3f%% \tpeak mem: %+6.3f%% \ttotal alloc: %+6.3f%%" | 50 | 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)) | 51 | name (100*(overallTime new / overallTime old - 1)) (100*(peakAllocF new / peakAllocF old - 1)) (100*(totalAllocF new / totalAllocF old - 1)) |
33 | --TODO | 52 | case output of |
34 | --writeFile "performance/release-0.5.perf" $ show new \ No newline at end of file | 53 | Nothing -> return () |
54 | Just n -> writeFile (resultPath </> n ++ ".perf") $ show new | ||