[erlang-questions] hrtime/0, Was: now/0 resolution

Serge Aleynikov saleyn@REDACTED
Thu Sep 13 04:58:33 CEST 2007


Here's a little test I ran on Linux (i386, 3GHz) to measure timer 
performance:

clock resolution: 0.010 s
gettimeofday() resolution: 4 us
gettimeofday() duration = 10 us
hrtime() resolution: 120 ns
hrtime() 1 iteration cost = 130 ns
clock_gettime() resolution = 461 ns
clock_gettime() 1 iteration cost = 117 ns


I also got a few private responses supporting community interest in an 
HR timer BIFs.  To address Mikael's question, I also think that both 
actual/virtual time BIFs could be useful.

Serge

Ulf Wiger (TN/EAB) wrote:
> Raimo Niskanen wrote:
>>
>> New question:
>>
>> Serge apparently want a new BIF e.g hrtime/0 that would return
>> the best high resolution time the implementation knows on the
>> running OS. The precision would be OS dependant, but the best
>> known to the emulator, and it would be the fastest way to get it.
>> This BIF could also be suitable for getting high resolution
>> CPU time as well as wallclock time.
>>
>> How much interest for such a BIF is there from the community?
>>
>> This would perhaps better be asked for in an EEP, but
>> this is a first poll.
> 
> We are very interested, and should even have this as a
> formal requirement somewhere (maybe it got lost along
> the way...)
> 
> What I've asked for in the past is a time value that has
> _at least_ millisecond precision, but I will gladly
> settle for the best precision available. (:
> 
> BR,
> Ulf W
> 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: time.c
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070912/93951468/attachment.c>


More information about the erlang-questions mailing list