5.2. Compiler options for profiling

-prof:

To make use of the profiling system all modules must be compiled and linked with the -prof option. Any SCC annotations you've put in your source will spring to life.

Without a -prof option, your SCCs are ignored; so you can compile SCC-laden code without changing it.

There are a few other profiling-related compilation options. Use them in addition to -prof. These do not have to be used consistently for all modules in a program.

-fprof-auto:

All bindings not marked INLINE, whether exported or not, top level or nested, will be given automatic SCC annotations. Functions marked INLINE must be given a cost centre manually.

-fprof-auto-top:

GHC will automatically add SCC annotations for all top-level bindings not marked INLINE. If you want a cost centre on an INLINE function, you have to add it manually.

-fprof-auto-exported:

GHC will automatically add SCC annotations for all exported functions not marked INLINE. If you want a cost centre on an INLINE function, you have to add it manually.

-fprof-auto-calls:

Adds an automatic SCC annotation to all call sites. This is particularly useful when using profiling for the purposes of generating stack traces; see the function traceStack in the module Debug.Trace, or the -xc RTS flag (Section 4.17.7, “RTS options for hackers, debuggers, and over-interested souls”) for more details.

-fprof-cafs:

The costs of all CAFs in a module are usually attributed to one “big” CAF cost-centre. With this option, all CAFs get their own cost-centre. An “if all else fails” option…

-fno-prof-auto:

Disables any previous -fprof-auto, -fprof-auto-top, or -fprof-auto-exported options.

-fno-prof-cafs:

Disables any previous -fprof-cafs option.

-fno-prof-count-entries:

Tells GHC not to collect information about how often functions are entered at runtime (the "entries" column of the time profile), for this module. This tends to make the profiled code run faster, and hence closer to the speed of the unprofiled code, because GHC is able to optimise more aggressively if it doesn't have to maintain correct entry counts. This option can be useful if you aren't interested in the entry counts (for example, if you only intend to do heap profiling).