library(stringr)
library(ggplot2)
library(rr4r)
ptn <- r"([\w]+://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?)"
url <- "https://mail.google.com/mail/u/0/"
res1 <- bench::press(
x = c(1, 1e3, 1e5),
{
bench::mark(
stringr = str_detect(rep(url, x), ptn),
rr4r = rr4r_detect(rep(url, x), ptn),
min_iterations = 100
)
}
)
#> Running with:
#> x
#> 1 1
#> 2 1000
#> 3 100000
autoplot(res1) +
ggtitle("Detection")
#> Loading required namespace: tidyr
res2 <- bench::press(
x = c(1, 1e3, 1e5),
{
bench::mark(
stringr = str_extract(rep(url, x), ptn),
rr4r = rr4r_extract(rep(url, x), ptn),
min_iterations = 100
)
}
)
#> Running with:
#> x
#> 1 1
#> 2 1000
#> 3 100000
autoplot(res2) +
ggtitle("Extraction")
Created on 2021-02-27 by the reprex package (v1.0.0)