Commit b39431a3 authored by Andreas Klebinger's avatar Andreas Klebinger

Support -t for all modes

parent 51fea932
......@@ -317,13 +317,17 @@ buildRules nofib@Build{..} = do
src <- liftIO $ readFile out
need [x | x <- words src, takeExtension x `elem` [".hs",".lhs",".h"]]
-- Run tests normally
["//Main.run.results.tsv"] &%> \[resultsTsv] -> do
runTest nofib ModeRun resultsTsv
-- Run tests under perf stat
["//Main.perf.result", "//Main.perf.results.tsv"] &%> \[out, resultsTsv] -> do
out' <- liftIO $ IO.canonicalizePath out
let test = testFromResultTsv nofib resultsTsv
let args = ["perf", "stat"] <> perf_args <> ["-x,", ("--output="++out'), "--append", "--"]
let parse_perf = do
stats <- PerfStatParse.readPerfStat out'
let args n = ["perf", "stat"] <> perf_args <> ["-x,", ("--output="<>out' <.> show n), "--"]
let parse_perf n = do
stats <- PerfStatParse.readPerfStat (out' <.> show n)
return $ Ms.fromList
[ (testLabel test <> ml "run" <> ml "perf" <> lbl, v)
| (eventName, vs) <- M.toList stats
......@@ -333,18 +337,14 @@ buildRules nofib@Build{..} = do
runTest nofib (ModeWrapped args parse_perf) resultsTsv
-- Run tests normally
["//Main.run.results.tsv"] &%> \[resultsTsv] -> do
runTest nofib ModeRun resultsTsv
-- Run tests under cachegrind
["//Main.cachegrind.result", "//Main.cachegrind.results.tsv"] &%> \[out, resultsTsv] -> do
out' <- liftIO $ IO.canonicalizePath out
let test = testFromResultTsv nofib resultsTsv
let wrapper_args = ["valgrind", "--tool=cachegrind"] <> cachegrind_args <>
[("--cachegrind-out-file="++out)]
let parse_cachegrind = do
stats <- CachegrindParse.parse out'
let wrapper_args n = ["valgrind", "--tool=cachegrind"] <> cachegrind_args <>
[("--cachegrind-out-file="<>out'<.>show n)]
let parse_cachegrind n = do
stats <- CachegrindParse.parse (out' <.> show n)
return $ Ms.fromList
[ (testLabel test <> ml "run" <> ml "cachegrind" <> lbl, realToFrac v)
| (eventName, v) <- M.toList stats
......@@ -353,16 +353,19 @@ buildRules nofib@Build{..} = do
runTest nofib (ModeWrapped wrapper_args parse_cachegrind) resultsTsv
data RunMode = ModeRun -- ^ Regular runtime measurement
| ModeWrapped [String] (IO (Measurements Double))
-- ^ Wrap the executable by a call to another executable like
-- perf or valgrind.
-- | Wrap the executable by a call to another executable.
--
-- For example perf or valgrind.
| ModeWrapped (Int -> [String])
(Int -> IO (Measurements Double))
getWrapperArgs :: RunMode -> [String]
getWrapperArgs ModeRun = []
getWrapperArgs :: RunMode -> (Int -> [String])
getWrapperArgs ModeRun = const []
getWrapperArgs (ModeWrapped args _) = args
getWrapperParser :: RunMode -> IO (Measurements Double)
getWrapperParser ModeRun = return mempty
getWrapperParser :: RunMode -> (Int -> IO (Measurements Double))
getWrapperParser ModeRun = \_ -> return mempty
getWrapperParser (ModeWrapped _ parser) = parser
---------------------------------------------------------------------
......@@ -390,21 +393,29 @@ runTest nofib@Build{..} runMode resultsTsv = do
(stdin, args) <- liftIO $ getTestCmdline nofib test
executable <- liftIO $ IO.canonicalizePath $ output </> testDir test </> "Main" <.> exe
let rtsStatsOut = executable <.> "stats"
-- Benchmark arguments
exec_args :: [String]
exec_args = [executable] <> args <> ["+RTS"] <> rts_args <> ["--machine-readable", ("-t"++rtsStatsOut)]
cmd_ (Cwd $ testDir test) (EchoStdout False) (StdinBS stdin)
(getWrapperArgs runMode) exec_args
wrapper_measurements <- liftIO (getWrapperParser runMode)
rtsStats <- liftIO $ readRtsStats rtsStatsOut
liftIO $ Ms.writeFileTsv resultsTsv $
wrapper_measurements <>
(Ms.prefix (testLabel test <> ml "run" <> ml "rts stats") rtsStats)
-- Create stats.0, stats.1, etc.
let doRun :: Int -> Action ()
doRun n = do
let rtsStatsOut = executable <.> "stats" <.> show n
cmd_ (Cwd $ testDir test) (EchoStdout False) (StdinBS stdin)
(getWrapperArgs runMode $ n)
executable args "+RTS" rts_args "--machine-readable" ("-t"++rtsStatsOut)
-- Run benchmarks n times
forM_ [1..times] $ \n -> doRun n
-- Read results
let doParse :: Int -> Action (Measurements Double)
doParse n = do
let rtsStatsOut = executable <.> "stats" <.> show n
wrapper_measurements <- liftIO (getWrapperParser runMode $ n) :: Action (Measurements Double)
rtsStats <- liftIO $ readRtsStats rtsStatsOut
return $
wrapper_measurements <>
(Ms.prefix (testLabel test <> ml "run" <> ml "rts stats") rtsStats)
measurements <- foldMap doParse [1..times :: Int] :: Action (Measurements Double)
liftIO $ Ms.writeFileTsv resultsTsv $ measurements
getTestConfig :: Nofib -> TestName -> Action (String -> String)
getTestConfig Build{..} test =
......
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