4.5. Runtime options for profiling

It isn't enough to compile your program for profiling with -prof!

When you run your profiled program, you must tell the runtime system (RTS) what you want to profile (e.g., time and/or space), and how you wish the collected data to be reported. You also may wish to set the sampling interval used in time profiling.

Executive summary: ./a.out +RTS -pT produces a time profile in a.out.prof; ./a.out +RTS -hC produces space-profiling info which can be mangled by hp2ps and viewed with ghostview (or equivalent).

Profiling runtime flags are passed to your program between the usual +RTS and -RTS options.

-p or -P:

The -p option produces a standard time profile report. It is written into the file <program>.prof.

The -P option produces a more detailed report containing the actual time and allocation data as well. (Not used much.)


The -px option generates profiling information in the XML format understood by our new profiling tool, see Section 4.3.


Set the profiling (sampling) interval to <secs> seconds (the default is 1 second). Fractions are allowed: for example -i0.2 will get 5 samples per second. This only affects heap profiling; time profiles are always sampled on a 1/50 second frequency.


Produce a detailed heap profile of the heap occupied by live closures. The profile is written to the file <program>.hp from which a PostScript graph can be produced using hp2ps (see Section 4.6).

The heap space profile may be broken down by different criteria:


cost centre which produced the closure (the default).


cost centre module which produced the closure.


closure description—a string describing the closure.


closure type—a string describing the closure's type.


The -hx option generates heap profiling information in the XML format understood by our new profiling tool (NOTE: heap profiling with the new tool is not yet working! Use hp2ps-style heap profiling for the time being).