Does anybody know if it is possible to make a high resolution timer in Erlang?
According to documentation all timers and timeouts are measured in milliseconds.
There is need to make a delay in microseconds. For example, instead of
timer:apply_after(MilliSec, Module, Function, Arguments).
something like
timer:apply_after(MicroSec, Module, Function, Arguments).
Indeed, all timers and timeouts primitives are in milliseconds including :
receive ... after primitive (which is what timer module eventually relies upon);erlang:send_after/3 and erlang:start_timer/3 which rely on the same mechanism;driver_set_timer function for linked in drivers.Two methods could be considered to achieve a sub-millisecond timer:
erlang:now() is not a real time function as it is guaranteed to be monotonous (and this is quite expensive). You should use os:timestamp() instead;If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With