Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

2 Answers 2

up vote 9 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

share|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

time can achieve this. In this case:

$ time foo.sh             
share|improve this answer

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