I need to profile a large number of haskell executables, hopefully in parallel. I managed to get the hour time from measure
and measTime
from the Criterion library, but could not get measCpuTime
either any GC report to work ( measCpuTime
returns a time that cannot be made short). The code looks like this:
buildProj :: FilePath -> IO ExitCode
buildProj projDir = system $ "cd " ++ projDir ++ "; cabal sandbox init; cabal configure; cabal build"
-- Time a project
instance NFData ExitCode
where
rnf ExitSuccess = ()
rnf (ExitFailure _) = ()
benchmark :: FilePath -> Int64 -> IO Double
benchmark projDir runs = do
let runProj = "./" ++ projDir ++ "/dist/build/" ++ projDir ++ "/" ++ projDir ++ "> /dev/null"
exit <- timeout 17000000 $ system runProj -- TODO hardcode timeout
case exit of
Just ExitSuccess -> do {(m, _) <- measure (nfIO $ system runProj) runs;
return $! measTime m}
Just (ExitFailure _) -> return 100
Nothing -> return 100
In short, I run executables with System.Process.system
as an input / output action, and I declared ExitCode
how NFData
to get nfIO
to work. What have I done wrong? Are there any better tools to accomplish this task?
The file is here if you want to play with it.