Profiling an executable file with a criterion

I need to profile a large number of haskell executables, hopefully in parallel. I managed to get the hour time from measureand measTimefrom the Criterion library, but could not get measCpuTimeeither any GC report to work ( measCpuTimereturns 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.systemas an input / output action, and I declared ExitCodehow NFDatato get nfIOto 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.

+4
1

SO . , criterion cbits, . , unix. - /proc/PID/stat/cutime . , c, , , .

0

Source: https://habr.com/ru/post/1611292/


All Articles