## 4.39 Obtaining Runtime Statistics

statistics(+Key, -Value)
  Unify system statistics determined by Key with Value. The possible keys are given in the table 5. The last part of the table contains keys for compatibility to other Prolog implementations (Quintus) for improved portability. Note that the ISO standard does not define methods to collect system statistics. Space unit is bytes64This may change to `cells' to enhance compatibility between the 32- and 64-bit versions.. Times are in seconds, represented as a floating point number. The Quintus compatibility keys express times in milliseconds.

  agc | Number of atom garbage-collections performed
  agc_gained | Number of atoms removed
  agc_time | Time spent in atom garbage-collections
  cputime | (User) CPU time since Prolog was started in seconds
  inferences | Total number of passes via the call and redo ports since Prolog was started.
  heap | Estimated total size of the heap (see section 2.18.1.1)
  heapused | Bytes heap in use by Prolog.
  heaplimit | Maximum size of the heap (see section 2.18.1.1)
  local | Allocated size of the local stack in bytes.
  localused | Number of bytes in use on the local stack.
  locallimit | Size to which the local stack is allowed to grow
  global | Allocated size of the global stack in bytes.
  globalused | Number of bytes in use on the global stack.
  globallimit | Size to which the global stack is allowed to grow
  trail | Allocated size of the trail stack in bytes.
  trailused | Number of bytes in use on the trail stack.
  traillimit | Size to which the trail stack is allowed to grow
  atoms | Total number of defined atoms.
  functors | Total number of defined name/arity pairs.
  predicates | Total number of predicate definitions.
  modules | Total number of module definitions.
  codes | Total amount of byte codes in all clauses.
  threads | MT-version: number of active threads
  threads_created | MT-version: number of created threads
  thread_cputime | MT-version: seconds CPU time used by finished threads. Supported on Windows-NT and later, Linux and possibly a few more. Verify it gives plausible results before using.
  Compatibility keys (times in milliseconds)
  runtime | [ CPU time, CPU time since last ] (milliseconds)
  system_time | [ System CPU time, System CPU time since last ] (milliseconds)
  real_time | [ Wall time, Wall time since last ] (see get_time/1)
  memory | [ Total unshared data, free memory ] (Uses getrusage() if available, otherwise incomplete own statistics.)
  stacks | [ global use, local use ]
  program | [ heap, 0 ]
  global_stack | [ global use, global free ]
  local_stack | [ local use, local free ]
  trail | [ trail use, 0 ]
  garbage_collection | [ number of GC, bytes gained, time spent ]
  stack_shifts | [ global shifts, local shifts, time spent ] (fails if no shifter in this version)
  atoms | [ number, memory use, 0 ]
  atom_garbage_collection | [ number of AGC, bytes gained, time spent ]
  core | Same as memory

  Table 5 : Keys for statistics/2

statistics
  Display a table of system statistics on the current output stream.
time(+Goal)
  Execute Goal just like once/1 (i.e., leaving no choice points), but print used time, 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.