real time and run time functions revisited



It would be nice if the built-in lisp program "time" worked, e.g.
?time(factor...);
But it doesn't in wxmaxima, anyway.

Perhaps something like it could bundle up a bunch of data including bytes
used etc in a maxima list.

The data available in GCL seems to be very modest compared to other
implementations; the amount of data potentially available in a more
"professional" lisp can be daunting, but sometimes quite useful. Like how
many floats are used, how much space in each of several generations of
allocated storage, etc.


RJF


> -----Original Message-----
> From: maxima-bounces at math.utexas.edu [mailto:maxima-
> bounces at math.utexas.edu] On Behalf Of Robert Dodier
> Sent: Thursday, December 28, 2006 2:47 PM
> To: Maxima list mailing
> Subject: real time and run time functions revisited
> 
> Hello, here is another attempt at some user-level time functions.
> Example session:
> 
> (%i1) [absolute_real_time(), ?sleep(5), absolute_real_time()];
> (%o1)            [3376334552, false, 3376334557]
> 
> (%i2) [elapsed_real_time(), ?sleep(5), elapsed_real_time()];
> (%o2)                 [12.91, false, 17.92]
> 
> (%i3) [elapsed_run_time(), ?sleep(5), elapsed_run_time()];
> (%o3)                  [0.02, false, 0.02]
> 
> (%i4) [elapsed_run_time(), factor(expand((a + b)^200)),
> elapsed_run_time()];
> (%o4)               [0.02, (b + a)^200, 1.39]
> 
> absolute_real_time returns number of seconds since 1900/01/01
> (as specified for the CL function get-universal-time).
> 
> Hope this helps,
> Robert
> 
> PS. Here is the code. initialize-real-and-run-time is called from
> cl-user::run (same place as some other initialization functions).
> 
> (let
>   ((t0-real 0) (t0-run 0)
>    (float-units (float internal-time-units-per-second 1d0)))
> 
>   (defun initialize-real-and-run-time ()
>     (setq t0-real (get-internal-real-time))
>     (setq t0-run (get-internal-run-time)))
> 
>   (defun $absolute_real_time () (get-universal-time))
> 
>   (defun $elapsed_real_time ()
>     (let ((elapsed-real-time (- (get-internal-real-time) t0-real)))
>       (/ elapsed-real-time float-units)))
> 
>   (defun $elapsed_run_time ()
>     (let ((elapsed-run-time (- (get-internal-run-time) t0-run)))
>       (/ elapsed-run-time float-units))))
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima