You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At least, I assume it's a windows issue. I tested it on a Ubuntu system and did not have the same issue.
Minimal Example:
importbirlimportbirl/durationimportgleam/erlang/processimportgleam/ioimportgleam/string// Based on https://github.com/bcpeinhardt/learn_otp_with_gleam/blob/681c23174fb24d0f7e92ca581fd71306eb4d3063/src/tasks.gleam#L158fntime(name:String,f:fn()-> a)-> a {letstart=birl.now()letx=f()letend=birl.now()io.println(name<>" start:\t"<>birl.to_naive_time_string(start))io.println(name<>" end: \t"<>birl.to_naive_time_string(end))letdifference=birl.difference(end,start)|>duration.decomposeio.println(name<>" took: \t"<>string.inspect(difference))x}pubfnmain(){// Sleep for 2 secondstime("timing test",fn(){process.sleep(2000)})}
Output on Ubuntu system (expected):
timing test start: 15:07:18.823
timing test end: 15:07:20.853
timing test took: [#(2, Second), #(28, MilliSecond), #(539, MicroSecond)]
Output on Windows system:
timing test start: 15:07:51.380
timing test end: 15:07:53.399
timing test took: [#(20, MilliSecond), #(174, MicroSecond)]
As you can see, printing the time works fine. It's just the difference that is the issue.
I'm not experienced enough to diagnose exactly what is going on, but I assume that the Duration type that normally takes microseconds is being given 100 microsecond intervals.
The text was updated successfully, but these errors were encountered:
I came across the same issue when I was timing my solutions for Advent of Code. I didn't think my Windows computer should be so much faster than my Linux VM.
At least, I assume it's a windows issue. I tested it on a Ubuntu system and did not have the same issue.
Minimal Example:
Output on Ubuntu system (expected):
Output on Windows system:
As you can see, printing the time works fine. It's just the difference that is the issue.
I'm not experienced enough to diagnose exactly what is going on, but I assume that the Duration type that normally takes microseconds is being given 100 microsecond intervals.
The text was updated successfully, but these errors were encountered: