[Armedbear-devel] single float representation and timing

Stas Boukarev stassats at gmail.com
Mon Jun 2 17:48:05 UTC 2014


bonasso <bonasso at traclabs.com> writes:

> The RAPs system I'm running in abcl makes extensive use of the
> difference between two sequential get-internal-real-time calls. But I
> get significantly different results in abcl than in acl.
>
> Here's an example:
>
> In acl:
>
> CL-USER(24): (setf foo (/ (get-internal-real-time)(float
> internal-time-units-per-second)))
> 8212185.5
> CL-USER(25): (setf bar (/ (get-internal-real-time)(float
> internal-time-units-per-second)))
> 8212195.0
> CL-USER(26): (- bar foo)
> 9.5 ;; nine+ seconds
>
> In abcl:
> CL-USER(15): (setf foo (/ (get-internal-real-time)(float
> internal-time-units-per-second)))
> 1.40157018E9
> CL-USER(16): (setf bar (/ (get-internal-real-time)(float
> internal-time-units-per-second)))
> 1.40157018E9
> CL-USER(17): (- bar foo)
> 0.0 ;; 0 seconds
>
> Thus, lots of time has to elapse between the calls before any
> difference is produced. (/ (get-internal-real-time)(float
> internal-time-units-per-second)) is the primitive time call used in
> the RAPs system.
>
> Of course the first thing I noticed is that the single floats in acl
> don't have the E notation.
> Is there a setting in abcl I can use to get the same behavior as in
> acl, or is there another problem going on?
>
(get-internal-real-time) => 1401731099641, that's too big to be
represented precisely as a single float. double float will work better.
And better divide by internal-time-units-per-second before doing
division. Even better would be to avoid converting into floats.

-- 
With best regards, Stas.

_______________________________________________
Armedbear-devel mailing list
Armedbear-devel at common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel



More information about the armedbear-devel mailing list