Tutorial by Examples

System time gives you the CPU time required to execute a R expression, for example: system.time(print("hello world")) # [1] "hello world" # user system elapsed # 0 0 0 You can add larger pieces of code through use of braces: system.time({ li...
At its simplest, proc.time() gives the total elapsed CPU time in seconds for the current process. Executing it in the console gives the following type of output: proc.time() # user system elapsed # 284.507 120.397 515029.305 This is particularly useful for benchmarking s...
One package for line profiling is lineprof which is written and maintained by Hadley Wickham. Here is a quick demonstration of how it works with auto.arima in the forecast package: library(lineprof) library(forecast) l <- lineprof(auto.arima(AirPassengers)) shine(l) This will provide you...
Microbenchmark is useful for estimating the time taking for otherwise fast procedures. For example, consider estimating the time taken to print hello world. system.time(print("hello world")) # [1] "hello world" # user system elapsed # 0 0 0 This i...
You can use the microbenchmark package to conduct "sub-millisecond accurate timing of expression evaluation". In this example we are comparing the speeds of six equivalent data.table expressions for updating elements in a group, based on a certain condition. More specifically: A data....

Page 1 of 1