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.
Occasionally, when running tests, I get:
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.