Measuring total execution time
When people say that their program is not performing well, they are often referring to the execution time or the time it takes to complete the execution of the program. Execution time is probably the most important performance measure in many contexts as it is has a direct impact on people and processes. A shorter execution time means the R programmer can perform his or her analysis more quickly to derive insights faster.
It turns out that execution time is also the easiest performance characteristic that can be measured accurately and in detail (though not always the easiest to solve). Therefore, we will start learning about the way to profile an R code by learning to measure the execution time of R programs. We will learn three different tools to do this: system.time()
, benchmark()
, and microbenchmark()
.
Measuring execution time with system.time()
The first profiling tool we will learn about is system.time()
. It is a very useful tool that we can use to measure...