Profiteur: a visualiser for Haskell GHC .prof files



Published on February 25, 2014 under the tag A nicer way to browse big profile filesPublished on February 25, 2014 under the tag haskell

Introduction

GHC comes with some amazing tools to do profiling of Haskell programs. In .prof files, you can see exactly in which function most time is spent and where most allocation is done.

However, at Erudify, we have a huge amount of Haskell code – and at this point .prof files can become very unwieldy, and the text representation is harder to grok.

This is why I coded profiteur, a simple HTML-based visualiser for GHC .prof files.

Screenshot of profiteur

Installation

Installation is easy:

$ cabal install profiteur

Usage

Let us grab a sample program from the HaskellWiki. The code of this sample program can be found in the appendix. I saved this file as binary-trees.hs .

First, we compile it with profiling enabled:

$ ghc --make -auto-all -prof -rtsopts binary-trees.hs [1 of 1] Compiling Main ( binary-trees.hs, binary-trees.o ) Linking binary-trees ...

We run it in profiling mode:

$ ./binary-trees 10 +RTS -p -RTS stretch tree of depth 11 check: -1 2048 trees of depth 4 check: -2048 512 trees of depth 6 check: -512 128 trees of depth 8 check: -128 32 trees of depth 10 check: -32 long lived tree of depth 10 check: -1

This generates the file binary-trees.prof . We can pass that to profiteur :

$ profiteur binary-trees.prof Wrote binary-trees.prof.html

Open the resulting file in your favorite (modern) browser and you are good to go! Here is the resulting HTML file so you can have a look without installing profiteur .

As always, patches and pull requests are welcome on GitHub.

Appendix

Code used: