use time command as a simple benchmark tool
October 20th, 2007 mysurface Posted in Calculation, time | Hits: 20355 |
Sometimes you need to track execution time for some apps for benchmarking, time command is a handy tool. Let say you have wrote few scripts trying to grep some info from some log files, each of the scripts uses different techniques or command combos. You can run your scripts along with time command, and compare their’s execution time.
Let’s assume you have written two script name script1.sh and script2.sh. You can do this
time ./script1.sh
Same thing to script2.sh, and the results will looks as bellow:
real 0m1.005s
user 0m0.000s
sys 0m0.008s
real shows you the execution time script1.sh takes, o minutes 1.005 seconds. user and sys tracks the CPU processing time. From the results, shows us that script1.sh uses 8 milliseconds CPU processing time in kernel mode (sys) and None in user mode.
Live Chat!







November 6th, 2007 at 10:47 am
Wow — that’s exactly what I needed. I wish I had a good, long script I could use it with, though. :(
December 9th, 2007 at 1:52 am
Thanks!
So simple but so useful
December 30th, 2008 at 4:46 am
Excellent!!!
Elegant as always, i love Linux :)
February 11th, 2009 at 9:22 am
Useful, thanks!
October 8th, 2009 at 3:27 am
I have a simple short script for test. (cursor)
The only output I can get is:
{$}[4] time ./cursor
0.005u 0.062s 0:06.85 0.8% 0+0k 0+0io 0pf+0w
If I try: time -f ./cursor or any other switch I get:
-f: Command not found.
even if I try time -V or –version it’s still: command not found… ???
February 15th, 2010 at 10:41 pm
I had the same problem.
try it with /usr/bin/time.
I found the solution at:
http://www.oreillynet.com/linux/cmd/cmd.csp?path=t/time