Kt Mack
Kt Mack

Reputation: 381

How to get the runtime of an R script?

I am running a single script in R using source('scriptname.R').

I would like to get the running time of this script.

Can someone advise me on how I can do this?

Upvotes: 6

Views: 6773

Answers (2)

Dirk is no longer here
Dirk is no longer here

Reputation: 368489

tl;dr: Wrap system.time(source("scriptname.R")) around it.

Longer answer: Read the "Writing R Extensions" manual about profiling your code, and look at a few of the profiling packages which help aggregate the raw profiling data. The newest, and possibly nicest is Hadley's lineprof package on github.

Upvotes: 8

Konrad Rudolph
Konrad Rudolph

Reputation: 545995

system.time should do:

system.time(source('scriptname.R'))

Upvotes: 4

Related Questions