Common Lisp provide a time
macro for finding out how long a form takes to execute, and it prints the information to the trace output:
time evaluates form in the current environment (lexical and dynamic). … time prints various timing data and other information to trace output. The nature and format of the printed information is implementation-defined. Implementations are encouraged to provide such information as elapsed real time, machine run time, and storage management statistics.
For instance:
(time (length (make-array 1000000)))
Real time: 0.0140014 sec.
Run time: 0.0 sec.
Space: 4000008 Bytes
GC: 1, GC time: 0.0 sec.
Is there a way to collect these parameters and push them step by step into some stack or list and return it from a function?
Some things are standard: get-internal-run-time and get-internal-real-time:
Others are not (space and GC count), you need to find the implementation-specific versions.
You might also consider using
with-timing
- it provides progress reports including ETA.Incidentally, in your code, memory allocation (
make-array
) dwarfslength
(which is slot access for an array).