[erlang-questions] Time Granularity on Windows
Rob A'Court
rob@REDACTED
Fri Jan 29 11:17:17 CET 2016
Hi
I'm trying to take some timings in our app.
I'm taking timestamps using erlang:monotonic_time when certain events happen but noticed that on windows these aren't what I’m expecting
The test below on linux logs the difference as being about 1ms. without the sleep its about 0.001ms which is what I would expect.
On windows, the diff is 16ms, even if i change the timer to 10ms sleep. without the timer the difference is always 0ms.
lists:foreach(fun(X) ->
First = erlang:monotonic_time(),
timer:sleep(1),
Second = erlang:monotonic_time(),
TimeDiff = erlang:convert_time_unit((Second - First), native, nano_seconds)/1000000,
io:write(TimeDiff),
io:format("\r\n")
end, lists:seq(1,100)).
Is this a problem with something I am doing or with the granularity of the windows system clock?
Is there another approach I could take to get accurate (~microsecond granularity) timestamps on windows and linux?
Many thanks
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160129/af5a4ed7/attachment.htm>
More information about the erlang-questions
mailing list