statistics/[0,2]

Synopsis

statistics

Displays statistics relating to memory usage and execution time.

statistics(+Keyword, -List)

statistics(*Keyword, *List)

Obtains individual statistics.

Arguments


Keyword atom
keyword such as runtime
List list of integer
list of statistics (see following table)

Times are given in milliseconds and sizes are given in bytes.


runtime
[cpu time used by Prolog, cpu time since last call to statistics/[0,2]]
system_time
[cpu time used by the operating system, cpu time used by the system since the last call to statistics/[0,2]]
real_time
[wall clock time since 00:00 GMT 1/1/1970, wall clock time since the last call to statistics/[0,2]]
memory
[total virtual memory in use, total virtual memory free]
stacks
[total global stack memory, total local stack memory]
program
[program space, 0]
global_stack
[global stack in use, global stack free]
local_stack
[local stack in use, local stack free]
trail
[size of trail, 0]
garbage_collection
[number of GCs, freed bytes, time spent]
stack_shifts
[number of global stack area shifts, number of local stack area shifts, time spent shifting]
atoms
[number of atoms, atom space in use, atom space free]
atom_garbage_collection
[number of AGCs, freed bytes, time spent]
core
(same as memory)
heap
(same as program)

Description

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:

Examples

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

See Also

ref-mgc-ove-sta