statistics/[0,2]
statistics
Displays statistics relating to memory usage and execution time.
statistics(
+Keyword,
-List)
statistics(
*Keyword,
*List)
Obtains individual statistics.
runtime
Times are given in milliseconds and sizes are given in bytes.
runtime
statistics/[0,2]
]
system_time
statistics/[0,2]
]
real_time
statistics/[0,2]
]
memory
stacks
program
global_stack
local_stack
trail
garbage_collection
stack_shifts
atoms
atom_garbage_collection
core
heap
statistics/0
displays various statistics
relating to memory usage, runtime and garbage collection, including
information about which areas of memory have overflowed and how much time
has been spent expanding them.
Garbage collection statistics are
initialized to zero when a Prolog session starts (this includes
sessions started from saved-states created by save_program/[1,2]
,
and includes re-starts caused when restore/1
is used). The
statistics increase until the session is over.
statistics/2
is usually used with Keyword instantiated to
a keyword such as runtime
and List unbound. The predicate
then binds List to a list of statistics related to the keyword.
It can be used in programs that depend on current runtime
statistical information for their control strategy, and in programs
that choose to format and write out their own statistical summaries.
If keyword is garbage_collection
the list returned contains three elements:
The output from
statistics/0
looks like this:
memory (total) 377000 bytes: 350636 in use, 26364 free program space 219572 bytes atom space (2804 atoms) 61024 in use, 43104 free global space 65532 bytes: 9088 in use, 56444 free global stack 6984 bytes trail 16 bytes system 2088 bytes local stack 65532 bytes: 356 in use, 65176 free local stack 332 bytes system 24 bytes 0.000 sec. for 0 global and 0 local space shifts 0.000 sec. for 0 garbage collections which collected 0 bytes 0.000 sec. for 0 atom garbage collections which collected 0 bytes 0.233 sec. runtime
To report information on the runtime of
a predicate p/0
, add the following to your program:
:- statistics(runtime, [T0|_]), p, statistics(runtime, [T1|_]), T is T1 - T0, format('p/0 took ~3d sec.~n', [T]).