mathr / blog / #

hp2pretty-0.8 released

hp2pretty is a program to graph heap profiles output by Haskell programs compiled by GHC. It makes images like this by default:


Today I hacked on it some more and added some new features, like --reverse to switch the order of the bands:


and --sort=stddev to sort by band standard deviation:


and --sort=name to sort by cost center name:


and --trace=50 to combine the last percentage of trace elements into one band:


and --bands=5 to show only a certain number of bands:


and the icing on the cake, --pattern to use pattern fills for low ink printing:


Here's the --help output, using the optparse-applicative package for command line arguments:

hp2pretty - generate pretty graphs from heap profiles

Usage: hp2pretty [--uniform-scale AXES] [--sort FIELD] [--reverse]
                 [--trace PERCENT] [--bands COUNT] [--pattern] FILES...
  Convert heap profile FILES.hp to pretty graphs FILES.svg

Available options:
  --uniform-scale AXES     Whether to use a uniform scale for all outputs. One
                           of: none (default), time, memory, both.
  --sort FIELD             How to sort the bands. One of: size (default),
                           stddev, name.
  --reverse                Reverse the order of bands.
  --trace PERCENT          Percentage of trace elements to
                           combine. (default: 1.0)
  --bands COUNT            Maximum number of bands to draw (0 for
                           unlimited). (default: 15)
  --pattern                Use patterns instead of solid colours to fill bands.
  FILES...                 Heap profiles (FILE.hp will be converted to
  -h,--help                Show this help text

Version 0.7 was also released this week, featuring a contributed bugfix in parsing. You can get the latest from git here:

git clone

or install from Hackage.