You are not logged in.

#1 2012-05-17 19:32:50

From: Sweet home Alabama!
Registered: 2009-06-27
Posts: 356

Question on time utility: time vs /usr/bin/time

I have a question on time measurement in Linux.

For example, I want to measure time for compression and network transfer with ssh piping (I want to measure execution time of entire process):

 (/usr/bin/time -f "%e" xz -kfc -file | ssh name@serverIP "cat > /dev/null") 2>>timelogfile.txt 

However, I have some suspicion about the script above. Especially after trying few other ways to measure time (just by using time and by using perf stat).
Does the time measurement only includes execution time of xz compression? Or does it also include time to do the piping through the network? Do I have that line written in such way that I only measure portion of that task?
To test my suspicion, I tried to run three different time measurement tools on one file. I was getting different data for all 3.

time vs /usr/bin/time especially different by 1 or 2 seconds (time giving large value, while /usr/bin/time giving smaller value):

 (time xz -kfc -file | ssh name@serverIP "cat > /dev/null") 2>>timelogfile.txt 
 (/usr/bin/time -f "%e" xz -kfc -file | ssh name@serverIP "cat > /dev/null") 2>>timelogfile.txt 

Last edited by kdar (2012-05-18 02:04:25)


#2 2012-05-23 22:31:45

From: Belgium
Registered: 2012-05-07
Posts: 265

Re: Question on time utility: time vs /usr/bin/time

1) You are only measuring the time for the compression. To include the time I suspect you need:

 time ( xz -kfc -file | ssh name@serverIP "cat > /dev/null") 2>>timelogfile.txt

2) The results for time and /usr/bin/time differ because running time starts the bash built-in time, running /usr/bin/time the normal time command.
man time says:

Note: some shells (e.g., bash(1)) have a  built-in  time  command  that
       provides less functionality than the command described here.  To access
       the real command, you may need to specify its pathname (something  like

edit: 3) Can someone tell me why "which time" tells me I don't have time in my path, but "man time" works?
edit:  Apparently I don't have time installed, which still leaves me wondering why "man time" works.

Last edited by Terminator (2012-05-23 22:36:57)


#3 2012-05-23 23:06:56

Inspector Parrot
Registered: 2011-11-29
Posts: 19,305

Re: Question on time utility: time vs /usr/bin/time

For terminator:

$ pacman -Qo /usr/share/man/man1/time.1.gz
/usr/share/man/man1/time.1.gz is owned by man-pages 3.41-1

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman


Board footer

Powered by FluxBB