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
instrumentation. Execution profiling is either globally on or
globally off for all compiled code. This is reflected by the
profiling
Prolog flag. When the flag is on, the information
gathered depends on the execution mode:
source_info
Prolog flag was on when the code was loaded;
otherwise, the number of calls per predicate. Calls that succeed
nondeterminately are detected.
A typical query pattern is:
| ?- [Load some code.] | ?- prolog_flag(profiling,_,on). | ?- [Run some queries.] | ?- prolog_flag(profiling,_,off). | ?- print_profile.
The predicate 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
of profile_data/1
. The predicate profile_reset/0
clears
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)
and the SICStus Prolog IDE (see SICStus Prolog IDE)
which both can visualize the profiling information.
profile_reset
since release 4.2, developmentprofile_data(
-Data)
since release 4.2,developmentprint_profile
since release 4.2,developmentprint_profile(
+Data)
since release 4.2,development