How do I profile Prelude functions?

Simon Marlow
Wed, 19 Mar 2003 12:00:05 -0000


> I can't find advice in the GHC manual on determining how much=20
> time your
> program spends in Prelude functions. I've discovered that I=20
> can alias a
> Prelude function e.g.
> > import Data.Set
> ....
> > myMkSet =3D mkSet
> ... which will give me a cost-centre for mkMySet. Isn't there=20
> an easier way to do this?

Sorry for the delay in answering your question.

We should really turn on -auto-all when compiling the libraries for
profiling, but we don't for several reasons:

  (a) it affects optimisations
  (b) it makes profiles harder to read
  (c) it makes the libraries a lot larger

these are all things we should fix (well, at least (a) and (b)).  For
(b), we really need a better tool for viewing the profiles: I have a
prototype for such a tool which uses Gtk+HS, which I'll try to
incorporate at some point.

You can of course compile up your own libraries with -auto-all turned
on.  Or alternatively, just use the workaround you discovered.