### 7.24 System statistics

- `statistics/0`, `statistics/2`
- `user_time/1`, `system_time/1`, `cpu_time/1`, `real_time/1`

#### 7.24.1 `statistics/0`, `statistics/2`

Templates

  `statistics
  statistics(?atom, ?list)`

Description

`statistics` displays statistics about memory usage and run times.

`statistics(Key, Value)` unifies `Value` with the current value of the statistics key `Key`. `Value` a list of two elements. Times are in milliseconds, sizes of areas in bytes.

Key | Description | Value
`user_time` | user CPU time | `[SinceStart, SinceLast]`
`system_time` | system CPU time | `[SinceStart, SinceLast]`
`cpu_time` | total CPU time (user + system) | `[SinceStart, SinceLast]`
`real_time` | absolute time | `[SinceStart, SinceLast]`
`local_stack` | local stack sizes (control, environments, choices) | `[UsedSize, FreeSize]`
`global_stack` | global stack sizes (compound terms) | `[UsedSize, FreeSize]`
`trail_stack` | trail stack sizes (variable bindings to undo) | `[UsedSize, FreeSize]`
`cstr_stack` | constraint trail sizes (finite domain constraints) | `[UsedSize, FreeSize]`

Note that the key `runtime` is recognized as `user_time` for compatibility purpose.

Errors

`Key` is neither a variable nor a valid key |  | `domain_error(statistics_key, Key)`
`Value` is neither a variable nor a list of two elements |  | `domain_error(statistics_value, Value)`
`Value` is a list of two elements and an element `E` is neither a variable nor an integer |  | `type_error(integer, E)`

Portability

GNU Prolog predicates.

#### 7.24.2 `user_time/1`, `system_time/1`, `cpu_time/1`, `real_time/1`

Templates

  `user_time(?integer)
  system_time(?integer)
  cpu_time(?integer)
  real_time(?integer)`

Description

`user_time(Time)` unifies `Time` with the user CPU time elapsed since the start of Prolog.

`system_time(Time)` unifies `Time` with the system CPU time elapsed since the start of Prolog.

`cpu_time(Time)` unifies `Time` with the CPU time (user + system) elapsed since the start of Prolog.

`real_time(Time)` unifies `Time` with the absolute time elapsed since the start of Prolog.

Errors

`Time` is neither a variable nor an integer |  | `type_error(integer, Time)`

Portability

GNU Prolog predicates.

Copyright (C) 1999-2009 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. More about the copyright