News for hackers. Stuff that matters.
Re:Why is reading lines from stdin much slower in C++ than P... by jjc4p on Sunday March 11, 2012 @09:10AM (#3690293)
What's bad about cat(1)?
Re:Why is reading lines from stdin much slower in C++ than P... by shabble on Sunday March 11, 2012 @11:24AM (#3690491)
Nothing, except it's entirely unnecessary for this task.

See "Useless use of cat awards" from days of yore: http://partmaps.org/era/unix/award.html#uucaletter

Re:Why is reading lines from stdin much slower in C++ than P... by truncate on Sunday March 11, 2012 @04:08PM (#3691140)
I still prefer cat, as one simple mistake of < to > and the file is gone.
Re:Why is reading lines from stdin much slower in C++ than P... by adobriyan on Sunday March 11, 2012 @07:21PM (#3691595)
OP intends to measure time to read data from file and maybe it process into internal representation.

cat(1) almost certainly internally buffers data (32KB here) thus context switches occurs. Shell creates pipe which is buffered inside kernel.

All of this muffles measurements.

What was one or several read(2) calls + processing is now one or several calls of maybe smaller sizes + whatever scheduling differences + in one of the examples OP used /usr/bin/time of the whole thing also.

This is of course is not visible because data were dumbed down by using time() which has horrible granularity, but when finer grained timer it'd be visible, I'm sure.