Added hook predicate user:prolog_predicate_name/2, taken from SWI-Prolog, to the profiler code.

This commit is contained in:
Paulo Moura 2010-10-21 20:15:17 +01:00
parent de06131ba4
commit 15a728ce6d

View File

@ -15,6 +15,12 @@
* *
*************************************************************************/
% hook predicate, taken from SWI-Prolog, for converting possibly explicitly-
% qualified callable terms into an atom that can be used as a label for
% describing a predicate; used e.g. on the tick profiler defined below
:- multifile(user:prolog_predicate_name/2).
:- meta_predicate profile_data(:,+,-).
profile_data(M:D, Parm, Data) :-!,
@ -125,9 +131,19 @@ showprofres(A) :-
'$display_preds'([NSum-P|Ps], Tot, SoFar, I, N) :-
Sum is -NSum,
Perc is (100*Sum)/Tot,
Next is SoFar+Sum,
Next is SoFar+Sum,
NextP is (100*Next)/Tot,
format(user_error,'~|~t~d.~7+ ~|~w:~t~d~50+ (~|~t~2f~6+%) |~|~t~2f~6+%|~n',[I,P,Sum,Perc,NextP]),
( ( P = M:F/A ->
G = M:H
; P = F/A,
G = H
),
functor(H, F, A),
user:prolog_predicate_name(G, PL) ->
true
; PL = P
),
format(user_error,'~|~t~d.~7+ ~|~w:~t~d~50+ (~|~t~2f~6+%) |~|~t~2f~6+%|~n',[I,PL,Sum,Perc,NextP]),
I1 is I+1,
'$display_preds'(Ps,Tot,Next,I1, N).