2

I need to benhmark another project in my program, and right now I'm doing

    system $ "cd " ++ projDir ++ "; cabal build"
    let runProj = system $ "cd " ++ projDir ++ "; cabal run > /dev/null"
    (m, _) <- measure (whnfIO runProj) runs

with criterion. I know cabal run will check if the project has been built every time it's called, but other than that does it produce significant overhead? Is there a better way to benchmark other projects within a haskell program?

rem
  • 893
  • 4
  • 18
  • 2
    I don't have specifics, but I can't imagine that this would be a good way to profile a Haskell program. Why not compile it and then benchmark running it directly? – Rein Henrichs Jul 26 '15 at 16:23
  • That's what I'm doing now, only that I'm compiling with cabal because I can specify ghc flags per project. – rem Jul 26 '15 at 16:27
  • I guess the question boils down to "how to benchmark a project within a haskell program". The criterion documentation explains how to benchmark pure function and IO action, so now I'm running the project as an IO aciton – rem Jul 26 '15 at 16:31
  • 1
    It wasn't what you were doing when I commented but I see you have changed your example code since. – Rein Henrichs Jul 26 '15 at 19:05
  • 3
    This seems like a pretty bad idea, unless it is actually `cabal run` that you want to benchmark. Why not add an executable to the package itself that depends on criterion and benchmarks the actual function you care about? Or at least add enough hooks to the other project that you can write that executable with the other package as a dependency. Down your current path lies madness. – Daniel Wagner Jul 26 '15 at 20:26
  • I will take the advice. But I'm still curious if there's any reason that the criterion library doesn't provide functionalities for benchmarking full projects? – rem Jul 27 '15 at 02:05

0 Answers0