See also
The note under Obtaining Runtime Statistics for further predicates.
Example
Note that this doesn't use SI units ... to be corrected.
?- statistics. % Started at Fri Apr 30 10:48:23 2021 % 0.266 seconds cpu time for 454,419 inferences % 5,836 atoms, 4,377 functors, 3,279 predicates, 46 modules, 134,535 VM-codes % % Limit Allocated In use % Local stack: - 116 Kb 2,128 b % Global stack: - 128 Kb 25 Kb % Trail stack: - 130 Kb 392 b % Total: 1,024 Mb 374 Kb 27 Kb % % 5 garbage collections gained 345,064 bytes in 0.000 seconds. % 6 atom garbage collections gained 1,323 atoms in 0.002 seconds. % 9 clause garbage collections gained 236 clauses in 0.000 seconds. % Stack shifts: 3 local, 7 global, 9 trail in 0.001 seconds % 2 threads, 0 finished threads used 0.000 seconds true.
See also
There is a full-fat statistics/1 from library(statistics)
(which is defined in file swipl/lib/swipl/library/statistics.pl
).
That predicate doesn't show up in this chapter of the manual but does show up in the manual page for library(statistics)
.
Generally one would use statistics/2 instead to select the subset of the statistics one is interested in.
%! statistics(-Stats:dict) is det. % % Stats is a dict representing the same information as % statistics/0. This convience function is primarily intended to % pass statistical information to e.g., a web client. Time % critical code that wishes to collect statistics typically only % need a small subset and should use statistics/2 to obtain % exactly the data they need.
For example, using a dict prettyprinter to format the dict instantiated by statistics/1.
The entries for time
, data
(incongruously with dictionary tagged counts
) and stacks
are "core statistics".
The entry for agc
is for the atom garbage collector.
The entry for cgc
is for the clause garbage collector.
There will be another entry for engine
if there are engines.
Entries may be missing if there is a problem collecting data. In particular, the thread entry will be missing in a single-threaded SWI-Prolog compilate (I think).
?- statistics(Dict),dict_pp(Dict,_{border:true}). +--------------------------------------------+ | statistics | +--------------------------------------------+ |agc : +-----------------+ | | | gc | | | +-----------------+ | | |count : 9 | | | |gained : 2354 | | | |time : 0.002973| | | |type : atom | | | |unit : atom | | | +-----------------+ | |cgc : +-----------------+ | | | gc | | | +-----------------+ | | |count : 13 | | | |gained : 427 | | | |time : 0.000292| | | |type : clause | | | |unit : clause | | | +-----------------+ | |data : +-------------------+ | | | counts | | | +-------------------+ | | |atoms : 5975 | | | |functors : 4583 | | | |modules : 66 | | | |predicates : 3578 | | | |vm_codes : 147584| | | +-------------------+ | |gc : +-----------------+ | | | gc | | | +-----------------+ | | |count : 14 | | | |gained : 1543328 | | | |time : 0.001641| | | |type : stack | | | |unit : byte | | | +-----------------+ | |shift : +-----------------+ | | | shift | | | +-----------------+ | | |global : 5 | | | |local : 3 | | | |time : 0.000764| | | |trail : 7 | | | +-----------------+ | |stacks : +---------------------------------+| | | stacks || | +---------------------------------+| | |global : +------------------+ || | | | stack | || | | +------------------+ || | | |allocated : 131040| || | | |name : global| || | | |usage : 103064| || | | +------------------+ || | |local : +------------------+ || | | | stack | || | | +------------------+ || | | |allocated : 118648| || | | |name : local | || | | |usage : 2272 | || | | +------------------+ || | |total : +----------------------+|| | | | stack ||| | | +----------------------+|| | | |allocated : 382784 ||| | | |limit : 1073741824||| | | |name : stacks ||| | | |usage : 105968 ||| | | +----------------------+|| | |trail : +------------------+ || | | | stack | || | | +------------------+ || | | |allocated : 133096| || | | |name : trail | || | | |usage : 632 | || | | +------------------+ || | +---------------------------------+| |thread : +-------------------+ | | | thread | | | +-------------------+ | | |count : 2 | | | |finished : 0 | | | |time : 0.000000| | | +-------------------+ | |time : +------------------------------+ | | | time | | | +------------------------------+ | | |cpu : 0.440282 | | | |epoch : 1619776457.253009| | | |inferences : 744920 | | | +------------------------------+ | +--------------------------------------------+