h3 id="sec:profiling-predicates">4.41.1 Profiling predicates
The following predicates are defined to interact with the profiler.
- 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.
- 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.
- 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:
- Show the only top N predicates. Default is 25.
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
- The profiler is not activated.
- The profiler collects CPU statistics.
- The profiler collects wall time statistics.
trueis accepted as a synonym for
cputimefor compatibility reasons.
- Switches the profiler to
falseand 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.