4 Built-in Predicates
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Notation of Predicate Descriptions
        • Character representation
        • Loading Prolog source files
        • Editor Interface
        • List the program, predicates or clauses
        • Verify Type of a Term
        • Comparison and Unification of Terms
        • Control Predicates
        • Meta-Call Predicates
        • Delimited continuations
        • Exception handling
        • Handling signals
        • DCG Grammar rules
        • Database
        • Declaring predicate properties
        • Examining the program
        • Input and output
        • Status of streams
        • Primitive character I/O
        • Term reading and writing
        • Analysing and Constructing Terms
        • Analysing and Constructing Atoms
        • Localization (locale) support
        • Character properties
        • Operators
        • Character Conversion
        • Arithmetic
        • Misc arithmetic support predicates
        • Built-in list operations
        • Finding all Solutions to a Goal
        • Forall
        • Formatted Write
        • Global variables
        • Terminal Control
        • Operating System Interaction
        • File System Interaction
        • User Top-level Manipulation
        • Creating a Protocol of the User Interaction
        • Debugging and Tracing Programs
        • Obtaining Runtime Statistics
          • statistics/2
          • statistics/0
          • time/1
        • Execution profiling
        • Memory Management
        • Windows DDE interface
        • Miscellaneous
    • Packages

4.40 Obtaining Runtime Statistics

statistics(+Key, -Value)
Unify system statistics determined by Key with Value. The possible keys are given in the table 6. This predicate supports additional keys for compatibility reasons. These keys are described in table 7.

Native keys (times as float in seconds)
agcNumber of atom garbage collections performed
agc_gainedNumber of atoms removed
agc_timeTime spent in atom garbage collections
atomsTotal number of defined atoms
c_stackSystem (C-) stack limit. 0 if not known.
cgcNumber of clause garbage collections performed
cgc_gainedNumber of clauses reclaimed
cgc_timeTime spent in clause garbage collections
clausesTotal number of clauses in the program
codesTotal size of (virtual) executable code in words
cputime(User) CPU time since thread was started in seconds
epochTime stamp when thread was started
functorsTotal number of defined name/arity pairs
globalAllocated size of the global stack in bytes
globalusedNumber of bytes in use on the global stack
globallimitSize to which the global stack is allowed to grow
global_shiftsNumber of global stack expansions
heapusedBytes of heap in use by Prolog (0 if not maintained)
inferencesTotal number of passes via the call and redo ports since Prolog was started
modulesTotal number of defined modules
localAllocated size of the local stack in bytes
local_shiftsNumber of local stack expansions
locallimitSize to which the local stack is allowed to grow
localusedNumber of bytes in use on the local stack
table_space_usedAmount of bytes in use by the thread's answer tables
trailAllocated size of the trail stack in bytes
trail_shiftsNumber of trail stack expansions
traillimitSize to which the trail stack is allowed to grow
trailusedNumber of bytes in use on the trail stack
shift_timeTime spent in stack-shifts
stackTotal memory in use for stacks in all threads
predicatesTotal number of predicates. This includes predicates that are undefined or not yet resolved.
indexes_createdNumber of clause index tables creates.
indexes_destroyedNumber of clause index tables destroyed.
process_epochTime stamp when Prolog was started
process_cputime(User) CPU time since Prolog was started in seconds
thread_cputimeMT-version: Seconds CPU time used by finished threads. Basically non-portable. Works on Linux, MacOSX, Windows and probably some more.
threadsMT-version: number of active threads
threads_createdMT-version: number of created threads
enginesMT-version: number of existing engines
engines_createdMT-version: number of created engines
Table 6 : Keys for statistics/2. Space is expressed in bytes. Time is expressed in seconds, represented as a floating point number.

Compatibility keys (times in milliseconds)
runtime[ CPU time, CPU time since last ] (milliseconds, excluding time spent in garbage collection)
system_time[ System CPU time, System CPU time since last ] (milliseconds)
real_time[ Wall time, Wall time since last ] (integer seconds. See get_time/1)
walltime[ Wall time since start, Wall time since last] (milliseconds, SICStus compatibility)
memory[ Total unshared data, free memory ] (Used is based on ru_idrss from getrusage(). Free is based on RLIMIT_DATA from getrlimit(). Both are reported as zero if the OS lacks support.)
stacks[ global use, local use ]
program[ heap, 0 ]
global_stack[ global use, global free ]
local_stack[ local use, local free ]
trail[ trail use, trail free ]
garbage_collection[ number of GC, bytes gained, time spent, bytes left ] The last column is a SWI-Prolog extension. It contains the sum of the memory left after each collection, which can be divided by the count to find the average working set size after GC. Use [Count, Gained, Time|_] for compatiblity.
stack_shifts[ global shifts, local shifts, time spent ]
atoms[ number, memory use, 0 ]
atom_garbage_collection[ number of AGC, bytes gained, time spent ]
clause_garbage_collection[ number of CGC, clauses gained, time spent ]
coreSame as memory
Table 7 : Compatibility keys for statistics/2. Time is expressed in milliseconds.
statistics
Display a table of system statistics on the stream user_error.
time(:Goal)
Execute Goal just like call/1 and print time used, number of logical inferences and the average number of lips (logical inferences per second). Note that SWI-Prolog counts the actual executed number of inferences rather than the number of passes through the call and redo ports of the theoretical 4-port model. If Goal is non-deterministic, print statistics for each solution, where the reported values are relative to the previous answer.