YAP 7.1.0
The Count Profiler

The count profiler works by incrementing counters at procedure entry or backtracking. More...

Detailed Description

The count profiler works by incrementing counters at procedure entry or backtracking.

It provides exact information:

:-
% get number of calls for each profiled procedure
setof(D-[M:P|D1],(current_module(M),profile_data(M:P,calls,D),profile_data(M:P,retries,D1)),LP),
% output so that the most often called
% predicates will come last:
write_profile_data(LP).
list_profile(Module) :-
% get number of calls for each profiled procedure
setof(D-[Module:P|D1],(profile_data(Module:P,calls,D),profile_data(Module:P,retries,D1)),LP),
% output so that the most often called
% predicates will come last:
write_profile_data(LP).
write_profile_data([]).
write_profile_data([D-[M:P|R]|SLP]) :-
% swap the two calls if you want the most often
% called predicates first.
format('~a:~w: ~32+~t~d~12+~t~d~12+~n', [M,P,D,R]),
write_profile_data(SLP).
format(+ T, :L)
setof( X,+ P,- B)

These are the current predicates to access and clear profiling data:


Class Documentation

◆ profile_data/3

class profile_data/3

profile_data( ?Na/Ar, ?Parameter, -Data_)

Give current profile data on Parameter for a predicate described by the predicate indicator Na/Ar If any of Na/Ar or Parameter are unbound, backtrack through all profiled predicates or stored parameters Current parameters are:

  • calls Number of times a procedure was called
  • retries Number of times a call to the procedure was backtracked to and retried
  • profile_reset

Reset all profiling information

◆ showprofres/1

class showprofres/1

showprofres( N)

Show profiling info for the top-most N predicates

The showprofres/0 and showprofres/1 predicates call a user-defined multifile hook predicate, user:prolog_predicate_name/2 , that can be used for converting a possibly explicitly-qualified callable term into an atom that will used when printing the profiling information