Merge branch 'master' of yap.dcc.fc.up.pt:yap-6

This commit is contained in:
Vitor Santos Costa 2010-10-24 21:31:52 +02:00
commit 9304fd52f7
3 changed files with 20 additions and 3 deletions

View File

@ -7298,6 +7298,7 @@ Show profiling info for the top-most @var{N} predicates.
@end table
The @code{showprofres/0} and @code{showprofres/1} predicates call a user-defined multifile hook predicate, @code{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.
@node Call Counting, Arrays, Profiling, Top
@section Counting Calls

View File

@ -247,7 +247,7 @@
% load library modules
:- use_module(library(tries)).
:- use_module(library(lists), [append/3, member/2, memberchk/2, delete/3]).
:- use_module(library(system), [delete_file/1, shell/1]).
:- use_module(library(system), [delete_file/1, shell/1, tmpnam/1]).
:- use_module(library(ordsets), [ord_intersection/3, ord_union/3]).
% load our own modules

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).