tarakc02 / ratelimitr

Rate limiting for R functions
Other
40 stars 0 forks source link

Overran a rate limit #13

Closed tarakc02 closed 7 years ago

tarakc02 commented 7 years ago

So every now and then, on a Windows 7 machine, I can get this to fail:

iter <- 10000
n <- 5
period <- .03
f <- limit_rate(microbenchmark::get_nanotime, rate(n = n, period = period))
res <- replicate(iter, f())
lagged_res <- c(rep(NA, n + 1), res[seq_len(iter - (n + 1))])
times <- (res - lagged_res) / 1E9
expect_gt(min(times, na.rm = TRUE), .03)

For the most recent run, sum(times < .03, na.rm = TRUE) = 3 (yikes!). Other times it was 1, and frequently it is 0. I have not yet been able to replicate this behavior on a Linux machine.