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

Rounding, precision #3

Closed
tarakc02 opened this issue Oct 31, 2016 · 0 comments
Closed

Rounding, precision #3

tarakc02 opened this issue Oct 31, 2016 · 0 comments

Comments

@tarakc02
Copy link
Owner

tarakc02 commented Oct 31, 2016

Occasionally, when running tests, I get:

1. Failure: rate limited function does not exceed limits (@test-limit-rate.R#11) 
`time11` is not strictly more than 0.01. Difference: -1.02e-16

The function is running too quickly, by about 1E-16 seconds. This can happen regardless of the specific limits involved (ie, if you limit to 1 call per 1.5 seconds, you'll still see cases where the second call is made 1.499999... seconds after the first one).

One way around this is to specify some minimum guarantee-able level of precision in the time measurements and then round every time measurement to the right number of decimal places (well, rounding up or down when necessary to guarantee that we don't cross the rate limit). I don't know that much about timing or precision of clock measurements on computers. From ?Sys.time(): "On almost all systems it will have sub-second accuracy, possibly microseconds or better. On Windows it increments in clock ticks (usually 1/60 of a second) reported to millisecond accuracy."

Perhaps to start, I should round to the 1/60 of a second.

@tarakc02 tarakc02 changed the title Tests sometimes do not pass Rounding, precision Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant