Why is piping into a cat faster than not a conveyor belt?

I just found out what to do find .slower than doing find . | cat. Here are the runtime results time find .3 times in my home directory:

First:
real    0m4.385s
user    0m0.546s
sys     0m2.072s

Second:
real    0m4.090s
user    0m0.514s
sys     0m1.798s

Third:
real    0m4.197s
user    0m0.508s
sys     0m1.905s

Executing time find . | catinstead significantly improves the results:

First:
real    0m2.988s
user    0m0.378s
sys     0m1.649s

Second:
real    0m2.768s
user    0m0.370s
sys     0m1.471s

Third:
real    0m2.768s
user    0m0.370s
sys     0m1.471s

As you can tell, it find . | catruns much faster. I'm really confused by this, the only thing that catdoes is copy its input into its output, right? I really don't know why this is happening, and I would be happy if anyone could tell me why this is so.

For the record here is the output find . | wc:

 246646  477986 25198490

Thank.

+4
source share
1 answer

find . , find . | cat. , . /dev/null ( , find . > /dev/null find . | cat > /dev/null), , | cat , .

, , , , , find , stdout, cat , , stdout, find .

+3

All Articles