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

time of day to greater than one second accuracy



For a reaction-time experiment, i need to record time of day down to
hundredth-seconds. What I need is not merely elapsed hundredth-seconds
during the experiment, but a hundredth-second accuracy version of
(lisp:get-decoded-time). It would return values like:

   48.88 53 18 25 3 1990
     ;s  m  h  d  m  y

So, the approach i tried is illustrated in the function TIME-TEST below. If
the sub-seconds were in sync with GET-DECODED-TIME, then i could cons up the
rest. Well, in other CL's they seem to be (Lucid and KCL), but in Genera
they aren't. Nor in Genera are they off by some nice constant. Where am I
going wrong here and what can i do to fix it?

any help appreciated,

tnx, f

;;; the fun

(defun time-test (n)
 (dotimes (i n)
   (let ((seconds (lisp:get-decoded-time)))
     (multiple-value-bind (secs remainder)
        (lisp:ffloor (lisp:get-internal-real-time)
		     lisp:internal-time-units-per-second)
      (declare (ignore secs))
      (let ((sub-seconds (/ remainder
			    (float lisp:internal-time-units-per-second))))
	(print (+ seconds sub-seconds)))))))


;;the results

OTHER CL:

> (time-test 100)         ;;just an excerpt to show sync

40.71 
40.750003 
40.760003 
40.790003 
40.830001 
40.880003 
40.890003 
40.92 
40.930002 
41.090004 
41.130001 
41.140003 
41.160005 
41.170003 
41.210007 
41.260001 



GENERA:

Command: (time-test 100)  ;;two excerpts to show out of sync

42.518936 
42.53224 
42.544525 
42.588535 
42.60184 
42.614124 
43.62743 
43.640736 
43.65404 
43.666325 

......

43.277378 
43.353123 
43.41044 
43.485157 
43.542477 
43.616173 
44.672466 
44.751278 
44.807575 
44.878197 
44.935516 
44.00614