[racket] How can I measure time in nanoseconds?

From: Jon Rafkind (rafkind at cs.utah.edu)
Date: Fri Nov 12 18:58:19 EST 2010

On 11/12/2010 03:58 PM, Neil Toronto wrote:
> Eli Barzilay wrote:
>> 5 minutes ago, Jakub Piotr Cłapa wrote:
>>> And in the case this is still not clear ;) the inexact part is not
>>> only about formal inexactnes but about limited timer resolution as
>>> well. Despite the CPU clock ticking more than once each nanosecond
>>> the procesor and OS does not really count the time this accurately.
>>> On normal OSes I would expect microsecond accuracy at best (but that
>>> is a guess; I didn't measure).
>>
>> Easy to do, just run
>>
>>   (- (current-inexact-milliseconds) (current-inexact-milliseconds))
>>
>> a few times.
>>
>
> Looping to collect 1000 differences, I consistently get a minimum of
> 0.0009765625 milliseconds = 0.9765625 microseconds. Nice guess, Jakub.
>
> I also get negative numbers, which is very weird.
>

well.. left to right evaluation..


Posted on the users mailing list.