NEW: time/1 (based on the SWI-Prolog time/1 predicate; request from Paulo Moura).
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2073 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
cfa2a8f75f
commit
ba31d8db97
@ -17,6 +17,7 @@
|
||||
|
||||
<h2>Yap-5.1.3:</h2>
|
||||
<ul>
|
||||
<li> NEW: time/1 (based on the SWI-Prolog time/1 predicate; request from Paulo Moura).</li>
|
||||
<li> FIXED: with 64 bits indexing would separate ints from atoms (obs from A N Saravanaraj).</li>
|
||||
<li> FIXED: duplicated clause when starting from trace (obs from A N Saravanaraj).</li>
|
||||
<li> FIXED: always remember wchar_t is unsigned in WIN32.</li>
|
||||
|
10
docs/yap.tex
10
docs/yap.tex
@ -6306,7 +6306,6 @@ Unify the current value of mutable term @var{M} with term @var{D}.
|
||||
Set the current value of mutable term @var{M} to term @var{D}.
|
||||
@end table
|
||||
|
||||
<<<<<<< yap.tex
|
||||
@node Global Variables, Profiling, Profiling, Term Modification, Top
|
||||
@section Global Variables
|
||||
|
||||
@ -7233,6 +7232,15 @@ This gives the clock time in milliseconds since starting Prolog.
|
||||
|
||||
@end table
|
||||
|
||||
@item time(:@var{Goal})
|
||||
@findex time/1
|
||||
@snindex time/1
|
||||
@cnindex time/1
|
||||
Prints the CPU time and the wall time for the execution of @var{Goal}.
|
||||
Possible choice-points of @var{Goal} are removed. Based on the SWI-Prolog
|
||||
definition (minus reporting the number of inferences, which YAP currently
|
||||
does not support).
|
||||
|
||||
@item yap_flag(?@var{Param},?@var{Value})
|
||||
@findex yap_flag/2
|
||||
@snindex yap_flag/2
|
||||
|
@ -125,4 +125,32 @@ key_statistics(Key, NOfEntries, TotalSize) :-
|
||||
key_statistics(Key, NOfEntries, ClSize, IndxSize),
|
||||
TotalSize is ClSize+IndxSize.
|
||||
|
||||
|
||||
|
||||
%% time(:Goal)
|
||||
%
|
||||
% Time the execution of Goal. Possible choice-points of Goal are removed.
|
||||
% Based on the SWI-Prolog definition minus reporting the number of inferences,
|
||||
% which YAP does not currently supports
|
||||
|
||||
:- meta_predicate time(:).
|
||||
|
||||
time(Goal) :-
|
||||
statistics(walltime, _),
|
||||
statistics(cputime, _),
|
||||
( catch(Goal, E, true)
|
||||
-> Result = yes
|
||||
; Result = no
|
||||
),
|
||||
statistics(cputime, [_, Time]),
|
||||
statistics(walltime, [_, Wall]),
|
||||
( Time =:= 0
|
||||
-> CPU = 'Inf'
|
||||
; CPU is truncate(Time/Wall*100)
|
||||
),
|
||||
TimeSecs is Time/1000,
|
||||
WallSecs is Wall/1000,
|
||||
format("% ~3f CPU in ~3f seconds (~|~t~d~3+% CPU)~n", [TimeSecs, WallSecs, CPU]),
|
||||
( nonvar(E)
|
||||
-> throw(E)
|
||||
; Result == yes
|
||||
).
|
||||
|
Reference in New Issue
Block a user