4 ms·
Yes they are. Why not just send it straight to /dev/null?
by isatty 9y ago
Yes they are. Why not just send it straight to /dev/null?
- wahern 9y ago1) Because splice(2) requires either the source or sink to be a pipe. The source is a regular file so the sink has to be a pipe. 2) Because the example Rust program(s), emulating yes(1), had no [simple] way to measure throughput except by piping to another program. We can't fairly compare program A that writes directly to /dev/null with program B that writes to a pipe even if program A can measure its throughput. 2a) What jwilk said. 3) For some reason I thought that glibc had optimizations to elide fwrites to /dev/null, and some of my code was using stdio (e.g. for the final trailing bytes less than the pagesize). I could've sworn either glibc or bash did this, but I can't find any mention of it, now. I realize it would be crazy difficult and ugly for glibc to do this (because of dup2, etc), but glibc does alot of crazy things, and in any event I didn't bother checking beforehand. Mostly it comes down to fairly comparing benchmarks and kernel facilities. Otherwise, yes, those would be classic examples of Useless Use of Cat.