Added hook predicate user:prolog_predicate_name/2, taken from SWI-Prolog, to the profiler code.
This commit is contained in:
parent
de06131ba4
commit
15a728ce6d
@ -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(:,+,-).
|
:- meta_predicate profile_data(:,+,-).
|
||||||
|
|
||||||
profile_data(M:D, Parm, Data) :-!,
|
profile_data(M:D, Parm, Data) :-!,
|
||||||
@ -127,7 +133,17 @@ showprofres(A) :-
|
|||||||
Perc is (100*Sum)/Tot,
|
Perc is (100*Sum)/Tot,
|
||||||
Next is SoFar+Sum,
|
Next is SoFar+Sum,
|
||||||
NextP is (100*Next)/Tot,
|
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,
|
I1 is I+1,
|
||||||
'$display_preds'(Ps,Tot,Next,I1, N).
|
'$display_preds'(Ps,Tot,Next,I1, N).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user