Next: , Previous: , Up: Grade modifiers   [Contents][Index]


3.4.2 Grade modifiers for profiling Mercury programs

In the absence of all of the grade modifiers in this group, the Mercury compiler generates executables that cannot be profiled. Mercury actually supports two completely separate profilers: mprof and mdprof.

mprof is effectively a Mercury clone of one of the standard profilers for C, namely gprof. Like many (if not most) profilers, it operates by recording what part of the program was executing when its process is sent a periodic profiling signal by the OS. Like gprof, at each profiling signal, it records what predicate it was executing at the time and where it was called from, but no more than that.

This works well for C, where each function typically has one job, but not for Mercury, which has many polymorphic predicates that can be used in the implementation of many different jobs, with many different performance behaviors. This is why Mercury also has mdprof, the Mercury deep profiler, which at each profiling signal records the identity of not just the immediate parent of the currently executing predicate, but effectively the identities of all its other ancestors as well. (This is the “deep context” after which the profiler is named.)

The two profilers operate differently and have different strengths and weaknesses. You can read more about both of them in Profiling.

.prof

Compiling programs in a grade that includes the .prof grade modifier generates executables that, when executed, generate files containing information that mprof, the gprof-style profiler, can use to tell you where the program is spending its time.


This grade modifier is compatible only with base grades that target C.

.memprof

Compiling programs in a grade that includes the .memprof grade modifier generates executables that, when executed, generate files containing information that mprof, the gprof-style profiler, can use to tell you where the program is allocating memory.


This grade modifier is compatible only with base grades that target C.

.profdeep

Compiling programs in a grade that includes the .profdeep grade modifier generates executables that, when executed, generate files containing information that mdprof, the Mercury deep profiler, can use to tell you both where the program is spending its time and where it is allocating memory.


This grade modifier is compatible only with LLDS base grades (which all target C).


Next: , Previous: , Up: Grade modifiers   [Contents][Index]