My projects and thoughts

Cat Makes Terminal Faster

Posted on 2013-09-04

Cat without arguments simply copies input to output. In this mode it doesn't do anything useful, and ought to just be overhead that makes things slower. Apparently not always.

$ time find
real	0m7.907s
user	0m0.176s
sys	0m0.444s

$ time find | cat
real	0m3.936s
user	0m0.060s
sys	0m0.220s

Personally I'm running rxvt-unicode, and I know this can also be reproduced in xterm with fastScroll enabled. No other terminal emulator that I tested showed this behavior.

As for the cause of this, I have no idea. Even though it might only affect a few users, this actually works to my advantage. Thus, I will let this remain a mystery. Let's just agree that profiling can be difficult.