[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: timing



> From: "Mark A. Tapia" <markt@dgp.toronto.edu>
> ...
> (defun date-stamp (elapsed)
>   (let (hh mm ss dd)
>     (setq ss (floor elapsed internal-time-units-per-second)
>           mm (floor ss 60)
>           ss (mod ss 60)
>           hh (floor mm 60)
>           mm (mod mm 60)
>           dd (floor hh 24)
>           hh (mod hh 24))
>     (format nil "~3d ~2d:~2d::~2d" dd hh mm ss)))

Speaking of the function FLOOR :-) wouldn't it be a bit better to make
use of the multiple values it returns, as in the following function...

(defun NEW-DATE-STAMP (elapsed)
  (multiple-value-bind (dd remainder1)
      (floor (floor elapsed internal-time-units-per-second)
             86400)                     ; 86400 = No. seconds per day
    (multiple-value-bind (hh remainder2)
        (floor remainder1 3600)         ;  3600 = No. seconds per hour
      (multiple-value-bind (mm ss)
          (floor remainder2 60)         ;    60 = No. seconds per min.
        (format nil "~3d ~2d:~2d::~2d" dd hh mm ss)))))

Using FLOOR's multiple values obviates the need for MOD.

Al Reich

 +------------------------------------------------------------------+
 | Alfred J. Reich, Ph.D.       Phone: (512) 386-4178               |
 | Knowledge-Based Systems      FAX:   (512) 386-4445               |
 | Org T210, Bldg 310           Internet: reich@austin.lockheed.com |
 | Lockheed - Austin Division   +-----------------------------------+ 
 | P.O. Box 17100               |
 | Austin, TX 78760-7100        |
 +-------------------------------