36:-
'$do_error'/2
use_system_module(
'$_errors', []).
84 '$runtime'(
Runtime,
_),
85 '$cputime'(
CPUtime,
_),
86 '$systime'(
SYStime,
_),
87 '$walltime'(
Walltime,
_),
88 '$statistics_heap_info'(
HpSpa,
HpInUse),
89 '$statistics_heap_max'(
HpMax),
90 '$statistics_trail_info'(
TrlSpa,
TrlInUse),
91 '$statistics_trail_max'(
TrlMax),
92 '$statistics_stacks_info'(
StkSpa,
GlobInU,
LocInU),
93 '$statistics_global_max'(
GlobMax),
94 '$statistics_local_max'(
LocMax),
95 '$inform_heap_overflows'(
NOfHO,
TotHOTime),
96 '$inform_stack_overflows'(
NOfSO,
TotSOTime),
97 '$inform_trail_overflows'(
NOfTO,
TotTOTime),
98 '$inform_gc'(
NOfGC,
TotGCTime,
TotGCSize),
99 '$inform_agc'(
NOfAGC,
TotAGCTime,
TotAGCSize),
100 '$statistics'(
Runtime,
CPUtime,
SYStime,
Walltime,
HpSpa,
HpInUse,
HpMax,
TrlSpa,
TrlInUse,
TrlMax,
StkSpa,
GlobInU,
LocInU,
GlobMax,
LocMax,
NOfHO,
TotHOTime,
NOfSO,
TotSOTime,
NOfTO,
TotTOTime,
NOfGC,
TotGCTime,
TotGCSize,
NOfAGC,
TotAGCTime,
TotAGCSize).
102'$statistics'(
Runtime,
CPUtime,
SYStime,
Walltime,
HpSpa,
HpInUse,
HpMax,
TrlSpa,
TrlInUse,
_TrlMax,
StkSpa,
GlobInU,
LocInU,
GlobMax,
LocMax,
NOfHO,
TotHOTime,
NOfSO,
TotSOTime,
NOfTO,
TotTOTime,
NOfGC,
TotGCTime,
TotGCSize,
NOfAGC,
TotAGCTime,
TotAGCSize)
:-
103 TotalMemory is HpSpa+StkSpa+TrlSpa,
104 format(user_error,
'memory (total)~t~d bytes~35+~n', [
TotalMemory]),
105 format(user_error,
' program space~t~d bytes~35+', [
HpSpa]),
106 format(user_error,
':~t ~d in use~19+', [
HpInUse]),
107 HpFree is HpSpa-HpInUse,
108 format(user_error,
',~t ~d free~19+~n', [
HpFree]),
109 format(user_error,
'~t ~d max~73+~n', [
HpMax]),
110 format(user_error,
' stack space~t~d bytes~35+', [
StkSpa]),
111 StackInUse is GlobInU+LocInU,
112 format(user_error,
':~t ~d in use~19+', [
StackInUse]),
113 StackFree is StkSpa-StackInUse,
114 format(user_error,
',~t ~d free~19+~n', [
StackFree]),
115 format(user_error,
' global stack:~t~35+', []),
116 format(user_error,
' ~t ~d in use~19+', [
GlobInU]),
117 format(user_error,
',~t ~d max~19+~n', [
GlobMax]),
118 format(user_error,
' local stack:~t~35+', []),
119 format(user_error,
' ~t ~d in use~19+', [
LocInU]),
120 format(user_error,
',~t ~d max~19+~n', [
LocMax]),
121 format(user_error,
' trail stack~t~d bytes~35+', [
TrlSpa]),
122 format(user_error,
':~t ~d in use~19+', [
TrlInUse]),
123 TrlFree is TrlSpa-TrlInUse,
124 format(user_error,
',~t ~d free~19+~n', [
TrlFree]),
125 OvfTime is (
TotHOTime+TotSOTime+TotTOTime)
/1000,
126 format(user_error,
'~n~t~3f~12+ sec. for ~w code, ~w stack, and ~w trail space overflows~n',
127 [
OvfTime,
NOfHO,
NOfSO,
NOfTO]),
128 TotGCTimeF is float(
TotGCTime)
/1000,
129 format(user_error,
'~t~3f~12+ sec. for ~w garbage collections which collected ~d bytes~n',
130 [
TotGCTimeF,
NOfGC,
TotGCSize]),
131 TotAGCTimeF is float(
TotAGCTime)
/1000,
132 format(user_error,
'~t~3f~12+ sec. for ~w atom garbage collections which collected ~d bytes~n',
133 [
TotAGCTimeF,
NOfAGC,
TotAGCSize]),
134 RTime is float(
Runtime)
/1000,
135 format(user_error,
'~t~3f~12+ sec. runtime~n', [
RTime]),
136 CPUTime is float(
CPUtime)
/1000,
137 format(user_error,
'~t~3f~12+ sec. cputime~n', [
CPUTime]),
138 SYSTime is float(
SYStime)
/1000,
139 format(user_error,
'~t~3f~12+ sec. systime~n', [
SYSTime]),
140 WallTime is float(
Walltime)
/1000,
141 format(user_error,
'~t~3f~12+ sec. elapsed time~n~n', [
WallTime]),
143'$statistics'(
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_).
280 '$nof_threads_created'(
TC).
282 '$thread_runtime'(
TR).
286 '$statistics_heap_info'(
HpM,
Hp),
291 '$statistics_stacks_info'(
StkSpa,
GlobInU,
LocInU),
292 GlobFree is StkSpa-GlobInU-LocInU.
294 '$statistics_stacks_info'(
StkSpa,
GlobInU,
LocInU),
295 LocFree is StkSpa-GlobInU-LocInU.
297 '$statistics_trail_info'(
TrlSpa,
TrlInUse),
298 TrlFree is TrlSpa-TrlInUse.
299statistics(garbage_collection,[
NOfGC,
TotGCSize,
TotGCTime])
:-
300 '$inform_gc'(
NOfGC,
TotGCTime,
TotGCSize).
301statistics(stack_shifts,[
NOfHO,
NOfSO,
NOfTO])
:-
302 '$inform_heap_overflows'(
NOfHO,
_),
303 '$inform_stack_overflows'(
NOfSO,
_),
304 '$inform_trail_overflows'(
NOfTO,
_).
306 '$statistics_atom_info'(
NOf,
SizeOf).
307statistics(static_code,[
ClauseSize,
IndexSize,
TreeIndexSize,
ExtIndexSize,
SWIndexSize])
:-
308 '$statistics_db_size'(
ClauseSize,
TreeIndexSize,
ExtIndexSize,
SWIndexSize),
309 IndexSize is TreeIndexSize+ ExtIndexSize+ SWIndexSize.
310statistics(dynamic_code,[
ClauseSize,
IndexSize,
TreeIndexSize,
CPIndexSize,
ExtIndexSize,
SWIndexSize])
:-
311 '$statistics_lu_db_size'(
ClauseSize,
TreeIndexSize,
CPIndexSize,
ExtIndexSize,
SWIndexSize),
312 IndexSize is TreeIndexSize+CPIndexSize+ ExtIndexSize+ SWIndexSize.
324 TotalSize is ClSize+IndxSize.
343:-
meta_predicate time(
0).
347 '$do_error'(instantiation_error,time(
Goal)).
350 '$do_error'(instantiation_error,time(
Goal)).
352 '$do_error'(type_error(callable,
Goal),time(
Goal)).
356 (
catch(
Goal,
E, true)
364 ; CPU is truncate(
Time/Wall*100)
366 TimeSecs is Time/1000,
367 WallSecs is Wall/1000,
368 format(user_error,
'% ~3f CPU in ~3f seconds (~|~t~w~3+% CPU)~n', [
TimeSecs,
WallSecs,
CPU]),
catch( : Goal,+ Exception,+ Action)
key_statistics(+ K,- Entries,- TotalSize)
must_be_callable( ?_Goal_ )
statistics(? Param,- Info)
time(:Goal) % % Time the execution of Goal
key_statistics(+ K,- Entries,- Size,- IndexSize)