R Language Code profiling System.time


Example

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({
    library(numbers)
    Primes(1,10^5)
})

Or use it to test functions:

fibb <- function (n) {   
    if (n < 3) {
        return(c(0,1)[n])
    } else {
        return(fibb(n - 2) + fibb(n -1))
    }
}

system.time(fibb(30))