The following predicates are defined to interact with the profiler.
- profile(:Goal)
- Execute Goal just like once/1,
collecting profiling statistics, and call
show_profile([]
)
.
With XPCE installed this opens a graphical interface to examine the
collected profiling data.
- profile(:Goal,
+Options)
- Execute Goal just like once/1.
Collect profiling statistics according to Options and call show_profile/1
with Options. The default collects CPU profiling and opens a
graphical interface when provided, printing theāplain' time usage
of the top 25 predicates as a ballback. Options are described below.
Remaining options are passed to show_profile/1.
- time(+Which)
- If Which is
cpu
(default), collect CPU timing
statistics. If wall
, collect wall time statistics based on
a 5 millisecond sampling rate. Wall time statistics can be useful if Goal
calls blocking system calls.
- show_profile(+Options)
- This predicate first calls prolog:show_profile_hook/1.
If XPCE is loaded, this hook is used to activate a GUI interface to
visualise the profile results. If not, a report is printed to the
terminal according to Options:
- top(+N)
- Show the only top N predicates. Default is 25.
- cumulative(+Bool)
- If
true
(default false
), include the time
spent in children in the time reported for a predicate.
- profiler(-Old,
+New)
- Query or change the status of the profiler. The status is one of
- false
- The profiler is not activated.
- cputime
- The profiler collects CPU statistics.
- walltime
- The profiler collects wall time statistics.
The value true
is accepted as a synonym for cputime
for compatibility reasons.
- reset_profiler
- Switches the profiler to
false
and clears all collected
statistics.
- noprofile(+Name/+Arity,
...)
- Declares the predicate Name/Arity to be invisible
to the profiler. The time spent in the named predicate is added to the
caller, and the callees are linked directly to the caller. This is
particularly useful for simple meta-predicates such as call/1, ignore/1, catch/3,
etc.