The time command chronicles
In a previous article, I said that I would take the time to do a benchmark comparison of VirtualBox 3.2 and VirtualBox 4.0.
What I had in mind was, to compile Apache from Ports on each, time it, and compare the results. Sound simple, right?
So, I loaded up FreeBSD and typed 'time[/COLOR]'.
The results:
….that doesn't look right – I'm probably missing a switch. I thought I'd do a 'man search' to see the manual pages for the time command. No luck.
Well, that doesn't help either. Time for Google. A search for 'freebsd man time' came up with this as the first result:
So sure enough the switches we need are -p and -h. Let's try them and see what happens.
time -h -p
Still fail.
After some more research stumbled upon the manual pages for IBM's AIX (for those who don't know it's a commercial version of Unix made by IBM).
I noticed this:
So let's try /usr/bin/time on FreeBSD and see what happens! (fingers crossed for explosion)
/usr/bin/time
Ehm... Le'ts try again with a command this time:
/usr/bin/time echo “bla”
OK..... It's a little different... now with the parameters -h -p
OK, so we have some results. But what's the difference between just 'time' and '/usr/bin/time' ?
And why even the output of '/usr/bin/time' is not the same as the output on linux.byexamples.com ? Where are the indications for minutes and seconds?
Back to the lab Pinky!
I found the answer for the /usr/bin/time part in this blog here (Link):
It seems that /usr/bin/time is the version of GNU for the time command. So the version that comes with FreeBSD is different and the version on linux.byexamples.com is also different. So it seems that time depends on what Shell you are running. Wait, what shell is FreeBSD shipped by default again?
So if default shell is FreeBSD, what happens if we change the shell according to these instructions to bash?
pkg_add -r bash
bash
Result:
So now we finally got the right 'time'. :D
Now I'm curious though...... is the 'time' command on the default CSH shell so bad?
More research on Google took us again to IBM's AIX documentation!
This has a complete list of the built-in CSH (C Shell) commands (Note!! The ones in the screenshot are not the complete list, there are a lot more on the link provided).
Quite a few!!!!!!!
Scroll down and click on the 'time' command:
So let's compare the CSH time command with the BASH 'time' command.
CSH (C Shell) time traceroute www.freebsd.org
BASH Shell
Conclusion:
All 3 versions of the 'time' command work fine. Which one you wish to use if up to your personal preference. There is no need to be intimated by the default 'time' command of the CSH (C Shell), and since it's always available with the standard FreeBSD installation I encourage it.
- Links Used/References:
- (IBM AIX)http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds5/time.htm
- (NixCraft)http://oliver.net.au/?p=26
- (Arrdino)http://www.cyberciti.biz/faq/howto-set-bash-as-your-default-shell/
- (IBM AIX)http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.baseadmn/doc/baseadmndita/c_builtin_cmds.htm