Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inaccurate timeouts #1

Closed
aentwist opened this issue Sep 5, 2024 · 2 comments
Closed

Fix inaccurate timeouts #1

aentwist opened this issue Sep 5, 2024 · 2 comments
Labels

Comments

@aentwist
Copy link
Owner

aentwist commented Sep 5, 2024

Timeouts are currently measured by,

for timeout / refresh_rate times do
    is_done <- body()
    if is_done then break
    wait refresh_rate
end for

However, the execution time of the body is not always negligible. Especially for small refresh rates the body time becomes extremely significant, in some cases ~6-60x the refresh rate. In these cases the wall time of the timeout is proportionally affected. That is, timeouts become 6-60x longer than specified.

Instead timeouts should be measured using a pure wall time approach,

t_start <- get_time()
t_end <- get_time()
while t_end - t_start < timeout do
    is_done <- body()
    if is_done then break
    wait refresh_rate

    t_end <- get_time()
end while

By factoring in the body time, this should keep them accurate.

@aentwist
Copy link
Owner Author

aentwist commented Sep 5, 2024

The suggested fix has an inaccurate refresh rate

@aentwist
Copy link
Owner Author

aentwist commented Sep 9, 2024

🎉 This issue has been resolved in version 1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant