Take the 2-minute tour ×

How do I time the running duration of R scripts?

I basically want an equivalent to the bash command time.

share|improve this question
The function you are looking for is system.time(). –  Ananda Mahto Apr 15 '13 at 13:12
You may also want to try searching here: entering [r] time in the search bar at the top right would get you results (with the R tag here) that lead to system.time() rather quickly. –  Dirk Eddelbuettel Apr 15 '13 at 13:53
add comment

3 Answers

up vote 6 down vote accepted

Use system.time, or take a look at the microbenchmark package.

share|improve this answer
add comment

You can also use benchmark function from rbenchmark package. See helpfile here

share|improve this answer
add comment

If it's a complicated script that can't be evaluated by system.time(), try:

start_time = proc.time()
<your script here>
end_time = proc.time()
print(end_time - start_time)

Obviously you need to run lines 1-3 as close to each other as possible.

There are some examples here.

share|improve this answer
add comment

Your Answer


