Will McDonald wrote:
On 14/03/07, John Summerfield debian@herakles.homelinux.org wrote:
Ryan Simpkins wrote:
Am I using time right to measure it?
No, you're timing the cat only.
I don't think that's the case, you know. If I run the following:
[summer@bilby ~]$ time sleep 10s;sleep 10s
real 0m10.011s user 0m0.000s sys 0m0.003s [summer@bilby ~]$ time sleep 10s|sleep 10s
real 0m10.002s user 0m0.001s sys 0m0.003s [summer@bilby ~]$ time sleep 10s | time sleep 10s 0.00user 0.00system 0:09.99elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+150minor)pagefaults 0swaps
real 0m10.011s user 0m0.000s sys 0m0.006s [summer@bilby ~]$
[wmcdonald@stella ~]$ ls -lh /tmp/messages.1 -rw-r--r-- 1 root root 4.3M Mar 14 20:03 /tmp/messages.1 [wmcdonald@stella ~]$ time cat /tmp/messages.1 1> /dev/null
real 0m0.018s user 0m0.001s sys 0m0.017s
[wmcdonald@stella ~]$ time cat /tmp/messages.1 | grep '*.foo' 1> /dev/null
real 0m0.047s user 0m0.021s sys 0m0.026s
Running both commands repeatedly shows similar time differences, I think 'time''s timing the execution time of the whole command.
I think that writing to a pipe is more expensive than writing to /dev/null. Needs buffering etc.
Try
time cat /tmp/messages.1 | grep \ | grep '*.foo' 1> /dev/null