JASON
JASON

Reputation: 7491

how to measure the running time of a program in terminal

If I run a program ./a.out, and want to measure the time this program run. Is there such a command?

>> ./a.out
>> time xxxx

Thanks!

Upvotes: 0

Views: 2562

Answers (3)

John3136
John3136

Reputation: 29265

time ./a.out works on most Linux systems...

For more detail use:
man time

Upvotes: 1

user3778845
user3778845

Reputation: 89

You can use the command

$ time ./a.out

Upvotes: 1

Deleted User
Deleted User

Reputation: 2541

SECONDS=0
run_your_program
echo $SECONDS

as an alternative to all the "time" suggestions bound to come up as answer. SECONDS is initialised to 0 when shell starts, therefore you can also do calculations on before-after values, instead of initialising it to a specific value yourself. Useful as a kind of lap timer

Upvotes: 3

Related Questions