Profiler

We shoudn't do performance optimalizations as a first thing. Do it after a function or feature is developed. Have a look at Not Today image.

system.time()

system.time() returns amount of time taken to evaluate an expression.

> system.time(readLines("http://www.jhsph.edu"))
   user  system elapsed
  0.003   0.002   0.820
system.time({
    lines <- readLines("http://www.jhsph.edu")
    print(lines)
})
# prints a lot lof lines...
   user  system elapsed
  0.184   0.038   0.675

Rprof

There are two function provided:

  • Rprof()

  • summaryRprof()

Do not use system.time and Rprof together!

Rprof(tmp <- tempfile())
example(glm)
Rprof()
summaryRprof(tmp)

More about profiler is here

Last updated