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