summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCsaba Hruska <csaba.hruska@gmail.com>2016-02-18 10:56:24 +0100
committerCsaba Hruska <csaba.hruska@gmail.com>2016-02-18 10:56:24 +0100
commit5f7bbe131b0645a74a0389172ab302e2b25ea9c7 (patch)
tree3e7b1bb946a9980e8b2f3b54e64489f9575c82b7 /test
parent4d920b114dd6712a7465e0c48e96440c9913ca72 (diff)
update todo
Diffstat (limited to 'test')
-rw-r--r--test/PerfReport.hs30
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 #-}
2import Data.Char 2import Data.Char
3import System.Directory 3import System.Directory
4import System.FilePath 4import System.FilePath
5import Text.Printf 5import Text.Printf
6import Control.Monad 6import Control.Monad
7import Options.Applicative
7import Data.Map (Map,(!)) 8import Data.Map (Map,(!))
8import qualified Data.Map as Map 9import 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
13resultPath = "performance" 14data Config
15 = Config
16 { resultPath :: String
17 , output :: Maybe String
18 }
14 19
15main = do 20sample :: Parser Config
21sample = Config
22 <$> pure "performance"
23 <*> optional (strOption (long "output" <> short 'o' <> metavar "FILENAME" <> help "output file name"))
24
25main :: IO ()
26main = 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
33comparePerf :: Config -> IO ()
34comparePerf 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