computation time information



Eric,

Here is an idea. Call a Lisp function to get the current time.
In this scheme, tick sets t0 = current time, and tock returns
current time minus t0.

(%i1) :lisp (let ((t0 0)) (defun $tick () (/ (setq t0
(get-internal-real-time)) (float internal-time-units-per-second)))
(defun $tock () (/ (- (get-internal-real-time) t0) (float
internal-time-units-per-second))))
$TOCK
(%i1) tick ();
(%o1)                  1.1666327180919E+9
(%i2) tock ();
(%o2)                       5.315524
(%i3) tock ();
(%o3)                       7.761513
(%i4) tick ();
(%o4)                 1.1666327291046849E+9
(%i5) tock ();
(%o5)                        4.65154
(%i6) (tick (), factor (exp (1729 * x) - 1), tock ());
(%o6)                       1.615842

The above definitions for tick and tock can be polished.
Maybe GET-INTERNAL-RUN-TIME should be called instead of
GET-INTERNAL-REAL-TIME. Unfortunately "run time" is not
precisely defined. Maybe tick and tock should return integers or
rationals instead of floats. Maybe tick should return 0 or true or
something (since the return value of GET-INTERNAL-REAL-TIME
is implementation-dependent). I hope the above is enough to get
started, in any case.

By the way, I tried the above with Clisp, GCL, and SBCL on Linux.
The code is pure Common Lisp so it should work for other Lisps.
I would be interested to hear if it works correctly for GCL on Windows.

best,
Robert Dodier