Skip to content

Understanding rate/throttle pool in req_throttle #101

@jchrom

Description

@jchrom

I may just be doing something silly, but these timings look off to me. I am using the CRAN version on Ubuntu 20.04 and R 4.1.2.

library(dplyr)
library(httr2)

get_throttled <- function(url, rate) {
  message(Sys.time())
  request(url) %>%
    req_throttle(rate) %>%
    req_method("get") %>% 
    req_perform()
}

urls <- rep("https://httpbin.org/status/200", 60)

system.time(x <- lapply(urls, get_throttled, rate = 1))

#  user  system elapsed 
# 0.666   0.125  34.302

system.time(x <- lapply(urls, get_throttled, rate = 30/60))

#  user  system elapsed 
# 0.826   0.199  64.362

system.time(x <- lapply(urls, get_throttled, rate = 10/60))

#  user  system elapsed 
# 1.344   0.646 183.221

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions