07.01.2014 Views

The Glorious Glasgow Haskell Compilation System User's Guide ...

The Glorious Glasgow Haskell Compilation System User's Guide ...

The Glorious Glasgow Haskell Compilation System User's Guide ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>The</strong> <strong>Glorious</strong> <strong>Glasgow</strong> <strong>Haskell</strong><br />

<strong>Compilation</strong> <strong>System</strong> User’s <strong>Guide</strong>,<br />

Version 6.10.4<br />

viii<br />

5 Profiling 96<br />

5.1 Cost centres and cost-centre stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96<br />

5.1.1 Inserting cost centres by hand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98<br />

5.1.2 Rules for attributing costs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99<br />

5.2 Compiler options for profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100<br />

5.3 Time and allocation profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100<br />

5.4 Profiling memory usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100<br />

5.4.1 RTS options for heap profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101<br />

5.4.2 Retainer Profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102<br />

5.4.2.1 Hints for using retainer profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102<br />

5.4.3 Biographical Profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102<br />

5.4.4 Actual memory residency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103<br />

5.5 hp2ps––heap profile to PostScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103<br />

5.5.1 Manipulating the hp file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104<br />

5.5.2 Zooming in on regions of your profile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105<br />

5.5.3 Viewing the heap profile of a running program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105<br />

5.5.4 Viewing a heap profile in real time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105<br />

5.6 Observing Code Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106<br />

5.6.1 A small example: Reciprocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106<br />

5.6.2 Options for instrumenting code for coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107<br />

5.6.3 <strong>The</strong> hpc toolkit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107<br />

5.6.3.1 hpc report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108<br />

5.6.3.2 hpc markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108<br />

5.6.3.3 hpc sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108<br />

5.6.3.4 hpc combine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109<br />

5.6.3.5 hpc map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109<br />

5.6.3.6 hpc overlay and hpc draft . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109<br />

5.6.4 Caveats and Shortcomings of <strong>Haskell</strong> Program Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . 110<br />

5.7 Using “ticky-ticky” profiling (for implementors) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110<br />

6 Advice on: sooner, faster, smaller, thriftier 112<br />

6.1 Sooner: producing a program more quickly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112<br />

6.2 Faster: producing a program that runs quicker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113<br />

6.3 Smaller: producing a program that is smaller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115<br />

6.4 Thriftier: producing a program that gobbles less heap space . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!