From a405c72d4d00388538ad84ca0692c900d29778c9 Mon Sep 17 00:00:00 2001 From: blob1807 <12388588+blob1807@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:13:27 +1000 Subject: [PATCH 1/3] Updated windows time period call Updated win32.time_begin_period to windows.timeBeginPeriod Added a note about calling windows.timeEndPeriod once you don't need accurate_sleep, as per MS's docs https://learn.microsoft.com/en-us/windows/win32/api/timeapi/nf-timeapi-timebeginperiod#remarks --- core/time/time.odin | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/time/time.odin b/core/time/time.odin index 10b71ee0d..92d6fb848 100644 --- a/core/time/time.odin +++ b/core/time/time.odin @@ -238,8 +238,9 @@ time_add :: proc "contextless" (t: Time, d: Duration) -> Time { // // Accuracy seems to be pretty good out of the box on Linux, to within around 4µs worst case. // On Windows it depends but is comparable with regular sleep in the worst case. -// To get the same kind of accuracy as on Linux, have your program call `win32.time_begin_period(1)` to +// To get the same kind of accuracy as on Linux, have your program call `windows.timeBeginPeriod(1)` to // tell Windows to use a more accurate timer for your process. +// Additionally your program should call `windows.timeEndPeriod(1)` when you're done. accurate_sleep :: proc "contextless" (d: Duration) { to_sleep, estimate, mean, m2, count: Duration From bc0a2b8d39462ae83f6517c03f79f8c909e67a53 Mon Sep 17 00:00:00 2001 From: blob1807 <12388588+blob1807@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:17:44 +1000 Subject: [PATCH 2/3] Update time.odin --- core/time/time.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/time/time.odin b/core/time/time.odin index 92d6fb848..7c177533c 100644 --- a/core/time/time.odin +++ b/core/time/time.odin @@ -240,7 +240,7 @@ time_add :: proc "contextless" (t: Time, d: Duration) -> Time { // On Windows it depends but is comparable with regular sleep in the worst case. // To get the same kind of accuracy as on Linux, have your program call `windows.timeBeginPeriod(1)` to // tell Windows to use a more accurate timer for your process. -// Additionally your program should call `windows.timeEndPeriod(1)` when you're done. +// Additionally your program should call `windows.timeEndPeriod(1)` once you're done. accurate_sleep :: proc "contextless" (d: Duration) { to_sleep, estimate, mean, m2, count: Duration From 8eed65ad4c48b271754ff0660bda0aa61a2f8625 Mon Sep 17 00:00:00 2001 From: blob1807 <12388588+blob1807@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:20:05 +1000 Subject: [PATCH 3/3] Update time.odin --- core/time/time.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/time/time.odin b/core/time/time.odin index 7c177533c..4807af840 100644 --- a/core/time/time.odin +++ b/core/time/time.odin @@ -240,7 +240,7 @@ time_add :: proc "contextless" (t: Time, d: Duration) -> Time { // On Windows it depends but is comparable with regular sleep in the worst case. // To get the same kind of accuracy as on Linux, have your program call `windows.timeBeginPeriod(1)` to // tell Windows to use a more accurate timer for your process. -// Additionally your program should call `windows.timeEndPeriod(1)` once you're done. +// Additionally your program should call `windows.timeEndPeriod(1)` once you're done with `accurate_sleep`. accurate_sleep :: proc "contextless" (d: Duration) { to_sleep, estimate, mean, m2, count: Duration