Calculate Time to run RMD Script

Hi All,

do we have any solution to calculate the execution time in Rmarkdown script.
Please let me know the easiest sollution, Because i am new to Rmarkdown

I create a variable called “start.time” Just before I load the data and a variable called end.time at the end and then subtract start.time from end.time.

start.time <- Sys.time()

end.time <- Sys.time()

elapsed.time <- round((end.time - start.time), 3)

You can also use some :package: to benchmark or time code

Example

bench::system_time(rmarkdown::render("test.Rmd", quiet = TRUE))
#> process    real 
#>  1.31s   2.85s 

You also have an internal function that could be used to show the time each step of the rendering process is taking, for the last rendering. It is in ms and the last call render is the total time the last render took. It is non exported but could be useful to identify issue.

> rmarkdown:::perf_timer_summary()
               time
knitr           160
pandoc         1010
post-processor 1670
pre-processor    80
render         2930

Hope it helps

Dont have idea how to use it in my script

So for more understanding
first i have declared
title: "testing_1"
output:
word_document:
reference_docx: new1.docx

after that i have a chunk for set up like width, warning, message = False

then i have chunk for library and path,
than i have a chunk for raw data files and sourcing (functions files)
at last i have my child chunks to execute and create a word file.
now please provide a solution to use at where and what to do......

Sorry but I do not understand what you want to do.

If you want to time code execution, look at the bench :package:

It is R code you can use in R chunks.