How to speed up rendering of html documents #7249
-
DescriptionIn my case I generate html files based on a quarto document and then take pictures of them using webshot2. Вut quarto_render function has a large overhead for render and saving the html file. For example, this code runs in 0.014 sec. tictoc::tic()
library(dplyr)
mtcars %>% select(params$col_name)
tictoc::toc() But render an html file already takes about 4 seconds.
repex_html.qmd
Is there a way to speed up rendering? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Quarto runs R as part of its processing but also does a lot of other things, and that takes time. I would say a fair comparaison would already be to compare with R run in a new background process. > tictoc::tic()
> res <- callr::r_safe(function() {
+ params = list()
+ params$col_name = "cyl"
+ library(dplyr)
+ mtcars %>% select(params$col_name)
+ })
> tictoc::toc()
1.52 sec elapsed Then there will be at least knitr and rmarkdown layer running, with a Pandoc conversion. This adds more second > tictoc::tic()
> res <- callr::r_safe(function() {
+ rmarkdown::render("test2.qmd")
+ })
> tictoc::toc()
3.01 sec elapsed Quarto does then do a lots of processing before and after pandoc renders, which adds some timing > tictoc::tic()
> quarto::quarto_render("test2.qmd", quiet = TRUE)
> tictoc::toc()
4.88 sec elapsed On my environment, 2 sec more. We are tracking performance and always trying to improve. Though, you won't be able to make a quarto rendering going as fast as just running R code in a R console. Quarto offers some options to manage execution to freeze or cache outputs : https://quarto.org/docs/projects/code-execution.html Hope it helps |
Beta Was this translation helpful? Give feedback.
-
Thanks for reply. Apparently, in my case, the best solution would be to check data relevance before rendering. |
Beta Was this translation helpful? Give feedback.
Quarto runs R as part of its processing but also does a lot of other things, and that takes time.
I would say a fair comparaison would already be to compare with R run in a new background process.
Then there will be at least knitr and rmarkdown layer running, with a Pandoc conversion. This adds more second
Quarto does then do a lots of processing before an…