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)

Arguments

all

whether to time all chunks by default (set the default value for chunk option time_it)

Details

And just wrap it in a function so you can simply write efun::time_chunk() in your top chunk, instead of the whole example.

Examples

if (FALSE) {
# Simply put this line on the top chunk of your .Rmd file
efun::time_chunk(all = TRUE)
}