Previous Up Next

4.12  Time and Memory

4.12.1  Timing

Timings are available via the built-in predicates cputime/1nd statistics/2 To obtain the CPU time consumption of a (succeeding) goal, use the scheme

TimeUsed is cputime-StartTime,
printf("Goal took %.2f seconds%n", [TimeUsed]).

The statistics/2 and statistics/0 commands can also be used to obtain memory usage information. The memory areas used by ECLiPSe are:

Shared and private heap
for compiled code, non-logical store ( bags and shelves, findall) dictionary of functors, various tables and buffers.
Global stack
for most ECLiPSe data like lists, structures, suspensions. This is likely to be the largest consumer of memory.
Local stack
for predicate call nesting and local variables.
Control and trail stack
for data needed on backtracking.

Automatic garbage collection is done on the global and trail stack, and on the dictionary. Garbage collection parameters can be set using set_flag/2 and an explicit collection can be requested using garbage_collect/0.

Previous Up Next