Execution profiling is a common aid for improving software performance.
As of release 4.2, execution profiling is available for compiled as well
as interpreted code. Execution profiling requires no recompilation with
source_info Prolog flag plays no role.
Execution profiling is either globally on or globally off
for all compiled code. This is reflected by the
flag. When enabled, execution profiling counts the number of calls per
caller-callee pair, and also detects calls that succeed
nondeterminately. In addition, for compiled code, the number of instructions
executed and choicepoints accessed per predicate are counted. While
execution profiling is enabled, profiling data is accumulated by simply
running the program. Compiled codes runs 2-10 times slower with execution profiling
than without. A typical query pattern is:
| ?- [Load some code.] | ?- prolog_flag(profiling,_,on). | ?- [Run some queries.] | ?- prolog_flag(profiling,_,off). | ?- print_profile.
profile_data/1 makes the accumulated data available
as a Prolog term. The predicate
print_profile/0 prints the
execution profile in a format similar to gprof(1). It can
also be given an argument which should be of the same type as the output
profile_data/1. The predicate
all profiling data. For the details, see the respective reference page.
See also the Gauge graphical user interface for inspecting execution
profiles (see lib-gauge).