Profiling with GHC is done by compiling with the
-prof parameter, which compiles the program with profile code that can be activated by executing the program with
./myprogram +RTS -p -RTS. This creates log file called
$ ./myfile +RTS -p -RTS
$ cat myfile.prof
Unfortunately this doesn’t work out-of-the-box. You have to install the profiling versions of all libraries and all depending libraries. And even more unfortunately, cabal doesn’t resolve dependencies for profiling libraries.
Update: To automatically install the profiling libraries for future installations edit the
~/.cabal/config and set the profiling options to
True. (thanks Erik)
Update2: You may only do this for libraries. I got leksah-server complaining about -N2 option not being available with profiling executable.
But the reinstallation produces errors like:
The export item `Permissions(Permissions, readable, writable,
attempts to export constructors or class methods that are not visible here
cabal: Error: some packages failed to install:
MissingH-22.214.171.124 depends on haskell98-126.96.36.199 which failed to install.
haskell98-188.8.131.52 failed during the building phase. The exception was:
>> Perhaps you haven't installed the profiling libraries for package
>> Use -v to see a list of the files searched for.
I also tried removing and recompiling some packages completely like so
$ cabal unpack MissingH
$ cd MissingH-184.108.40.206/
$ cabal configure -prof
$ cabal build
$ cabal install
There are some fundamental libraries which cannot be installed via cabal (like
parsec3), so you rather have to:
But eventually I found out that my packages are broken anyway (check with
ghc-pkg check) and I had to reinstall Haskell platform, which also didn’t work because:
$ sudo apt-get purge ghc6
$ sudo apt-get install --reinstall haskell-platform
I will publish the profiles as soon as I get a new power supply, hmpf :/