Possible Duplicate:
Measure script execution time

How would I time how long it takes for my script foo.sh to run?

I'm looking for something akin to tic and toc in MATLAB.

link|improve this question

1  
have you tried wrapping your code in time {} – MaxMackie Apr 4 '11 at 0:05
feedback

closed as exact duplicate by Wuffers, studiohack Apr 4 '11 at 1:52

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

2 Answers

up vote 2 down vote accepted

Use the unix time command

time ./sript.sh

If you're interested in ticks, you can approximate it with a little help from /proc/cpuinfo

link|improve this answer
time is a shell keyword – Hello71 Apr 25 '11 at 23:21
@Hello71 my linux bash does not provide a time command, it uses /usr/bin/time. However zsh does, as well as my solaris tcsh. So even if it's not builtin your shell, you have a time provided by your userland as a fallback. Besides, those time commands may provide a slightly different output. – mbx Apr 26 '11 at 9:45
@Hello71 although reserved, on that ystem which time returns userland time instead of the reserved keyword warning – mbx Apr 26 '11 at 21:20
@mbx: which never does that. I'm referring to type. – Hello71 Apr 26 '11 at 21:21
show 1 more comment
feedback

time can achieve this. In this case:

$ time foo.sh             
link|improve this answer
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.