user1521655
user1521655

Reputation: 484

Equivalent of bash command **time**

How do I time the running duration of R scripts?

I basically want an equivalent to the bash command time.

Upvotes: 2

Views: 182

Answers (3)

Alex
Alex

Reputation: 15718

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.

Upvotes: 0

Jilber Urbina
Jilber Urbina

Reputation: 61204

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

Upvotes: 3

juba
juba

Reputation: 49033

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

Upvotes: 6

Related Questions