library(logrrr)
logstdout <- logrrr::Logrrr$new()
logfile <- logrrr::Logrrr$new()
jsonfile <- tempfile(fileext=".txt")
txtfile <- tempfile(fileext=".txt")
logjson <- Logrrr$new(output = list(file = LogOutput$new(format_func = JSONFormatter(), output = jsonfile)))
logtxt <- Logrrr$new(output = list(file = LogOutput$new(format_func = TextFormatter(no_color = TRUE), output = txtfile)))
logmsgs <- function(lgr, n) {
lapply(1:n, function(x) {
lgr$with_fields(n = x)$info("message")
})
return(TRUE)
}
catmsgs <- function(n) {
lapply(1:n, function(x) {
cat(glue::glue("level: INFO n={x}\n\n"), file = stdout())
})
return(TRUE)
}
bmr <- bench::mark(
logmsgs(logstdout, 1),
logmsgs(logstdout, 100),
logmsgs(logstdout, 1000),
logmsgs(logtxt, 1),
logmsgs(logtxt, 100),
logmsgs(logtxt, 1000),
logmsgs(logjson, 1),
logmsgs(logjson, 100),
logmsgs(logjson, 1000),
check = FALSE
)
library(tidyverse)
bmr %>% mutate(n = as.numeric(str_extract(expression, "\\d+")),
type = str_replace(expression, "logmsgs\\(", ""),
type = str_replace(type, ",.+$", "")
) %>% select(type, n, median, max, n_gc) %>% arrange(n)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.