[erlang-questions] now/0 resolution

Serge Aleynikov saleyn@REDACTED
Fri Sep 7 14:23:34 CEST 2007


Since according to documentation consecutive executions of now/0 will 
return different values (with microsecond precision) I have two questions:

1. Does it mean that inserting now/0 calls in code will slow down 
execution to 1mks per execution?  If not, then performance of function 
call measured using now/0 time stamping would be inaccurate.

2. Is it possible to measure execution time more accurately (with 
nanosecond precision) using current Erlang distribution? (*)

Serge

(*) Since VM uses gettimeofday() to bump timer, it's limited by 
getimeofday's precision.  Additionally each invocation of gettimeofday 
takes about 15mks (OS dependent).  I believe that there's no code to 
take advantage of a high resolution timer.  Such a timer can give 
nanosecond precision, and presently the only way it can be implemented 
is in a linked-in driver.  The only problem that calling functions 
inside the driver with erlang:port_call/3 incurs some cost that would be 
better to avoid if a bif (such as hrnow/0) was available.




More information about the erlang-questions mailing list