Understanding UNIX `time` command output
Bizarrely, I couldn’t find any documentation as to the output from the UNIX (BASH shell version 3.2.57(1)-release, here) `time` command. I thought I had it, but I wanted to be sure, so I wrote a quick shell script to verify my understanding. A script that takes 1 minute, 5 seconds to run will have output that looks something like this:
iMac:~ me$ cat time_test.sh
#!/bin/bash
sleep 65
echo "Done."
iMac:~ me$ time ./time_test.sh
Done.
real 1m5.016s
user 0m0.003s
sys 0m0.006s
An hour, 2 minutes, and 8 seconds (sleep 3728):
real 62m8.083s
user 0m0.003s
sys 0m0.007s
A script that completes in approximately 2 seconds (sleep 2):
real 0m2.014s
user 0m0.003s
sys 0m0.006s
Mystery solved.
Comments
Post a Comment