By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Speeding up redirection to NUL?

Well, I can control what my app does, but not what hundreds of others do ... others which I might want to redirect to NUL. Can you give me some idea why these times are so different and what my app is supposed to do to make redirection to NUL faster? Below, wc is an external and lc is a plugin version of "wc -l".
l:\projects\perms\release> timer & perms abcdefghij | wc -l & timer
Timer 1 on: 11:42:42
Timer 1 off: 11:42:43  Elapsed: 0:00:01.50

l:\projects\perms\release> timer & perms abcdefghij > nul & timer
Timer 1 on: 11:42:49
Timer 1 off: 11:43:15  Elapsed: 0:00:26.24

l:\projects\perms\release> timer & perms abcdefghij | lc & timer
Timer 1 on: 11:45:13
Timer 1 off: 11:45:15  Elapsed: 0:00:01.44
I must not know what you mean. My app uses a single printf() statement. If I change stdout to unbuffered, like this,
setvbuf(stdout, NULL, _IONBF, 0);
then the (already outrageous) time of 26 seconds jumps to over 10 minutes!
OTOH, if I give stdout a large buffer, like this,
setvbuf(stdout, NULL, _IOFBF, 65536);
I cut the 26 seconds to 1.4 seconds (about where it should be). If I also
_setmode(_fileno(stdout), _O_BINARY); // also change "\n" to "\r\n"
I can get it down to 1.2 seconds.

Similar threads