This function takes knitr's official example on using chunk hooks to report how much time each chunk takes to run: https://bookdown.org/yihui/rmarkdown-cookbook/time-chunk.html
time_chunk(all = TRUE)
whether to time all chunks by default (set the default value for
chunk option time_it
)
And just wrap it in a function so you can simply write efun::time_chunk()
in your top chunk, instead of the whole example.
if (FALSE) {
# Simply put this line on the top chunk of your .Rmd file
efun::time_chunk(all = TRUE)
}