profile(:Goal)
profile(:Goal,
+Options)Run once(Goal) under the execution profiler. If the (xpce)
GUI is enabled this predicate is hooked by library(swi/pce_profile)
and results are presented in a gui that enables navigating the call tree
and jump to predicate implementations. Without the GUI, a simple textual
report is generated. Defined options are:
- time(Which)
- Profile
cpu or wall time. The default is CPU
time.
- exact(Exact)
- If
true, do not sample, but read the clock each time
execution moves to another node of the call tree. This gives exact wall
times, also for short running goals. For CPU time, the thread's CPU time
is read once per sample period (see
sample_rate(Rate)) and after each long interval, where the
thread may have been off the CPU. If auto, use exact timing
if reading the clock is cheap and, for CPU time, the thread CPU clock is
precise. This is typically not the case in virtual machines. Otherwise
use sampling. Default is defined by the Prolog flag profile_exact,
which defaults to
auto.
- sample_rate(Rate)
- Samples per second, any numeric value between 1 and 1000. Default is
defined by the Prolog flag profile_sample_rate, which defaults to
200.
- ports(Bool)
- Specifies ports counted -
true (all ports), false
(call port only) or classic (all with some errors).
Accomodates space/accuracy tradeoff building call tree. Default is
defined by the Prolog flag profile_ports, which defaults to true.
- top(N)
- When generating a textual report, show the top N predicates.
- cumulative(Bool)
- If
true (default false), show cumulative
output in a textual report.
- See also
- show_coverage/2 from
library(test_cover).
- To be done
- The textual input reflects only part of the information.
- Enhanced in 10.1.20 (👉254121c) the text report of profile/2 lists XPCE methods and keeps its columns aligned
- Enhanced in 10.1.17 (👉b453a6a) profile/1: handle interrupts while collecting data.