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

Re: encode-universal-time performance



Sam Steingold <sshteingold@cctrading.com> writes:
> 
>      The major bottleneck of my code is computing the number of days 
>      between 2 dates. Now I convert both dates to the universal time 
>      (bignum of secs since the epoch) and take the difference divided by 
>      24*60*60. Is there a faster way to do that? profiling shows that I 
>      spend all the time encoding universal time, and I wonder if there is a 
>      way to avoid that.

The way you do it is the Right Way. Universal time has been introduced
into Common Lisp for precisely the purpose of computing the amount of
time elapsed between two days.

How many calls to `encode-universal-time' do you have? A call to
`encode-universal-time' takes 0.2 msec on a Pentium 100 MHz, and 0.9 msec
on an old Sparc 2. If you are calling `encode-universal-time' many
times for the same arguments, maybe you should cache the resulting
universal time.

Bruno