20100105

profiling your Haskell program: enable profiling for libraries

Having read this chapter in Real World Haskell, I wanted to profile the program I'm working on.
http://book.realworldhaskell.org/read/profiling-and-optimization.html
Unfortunately, right away I got errors because profiling hadn't been enabled for the modules I was importing. The Haskell wiki has this page:
http://www.haskell.org/haskellwiki/How_to_profile_a_Haskell_program
The process described there for enabling profiling in libraries is fine if you just need one library, but as it turned out, I needed to enable profiling in about six libraries. What a pain!

In the section called 2.2 Enable profiling on libraries, this information should absolutely be included, particularly the answer:
http://stackoverflow.com/questions/1704421/cabal-not-installing-dependencies-when-needing-profiling-libraries
You just need to do this:
vim ~/.cabal/config
Uncomment this line and set it to True:
library-profiling: True
After that, you need to cabal install __(module)__ --reinstall for each module you are using, and their dependencies as well. Unfortunately, cabal isn't smart enough to do it all the way down automatically yet.

That is so much easier than doing each library by hand, though. I was about to get really frustrated until I read that post on StackOverflow.

No comments: