I found some strange behavior when testing output speed. The following program outputs the letter A 500,000 times to a file named as an argument, or to stdout by default.
Code:
// t.cpp
#include <stdio.h>
int main(int argc, char** argv) {
FILE* out=stdout;
if (argc==2) out=fopen(argv[1], "wb");
for (int i=0; i<500000; ++i) putc('A', out);
return 0;
}
The following commands all run in less than 0.05 seconds:
Code:
t x (write to file x)
t nul: (discard output)
t > x (redirect stdout to file x)
copy x x1
copy x nul:
type x > x1
type x > nul:
But the following takes 14 seconds. 
I get the same behavior whether I compile with g++ v4.6.1 (g++ -O3 -fomit-frame-pointer, also g++ with no optimization) or Microsoft 16.00.30319.01 (cl /O2 or cl). I'm testing under Vista SP2 32 bit on a 2.0 GHz T3200. I tried varying the output size, and time is proportional. Anyone else see this behavior?
Edit: same problem in Windows 7 Enterprise 32 bit, Intel Core i7 M620, 2.67 GHz, except it only takes 7 seconds because it's a faster machine.
Edit: the problem does NOT occur in Windows XP home edition (2002 SP3) 32 bit on a 2.2 GHz Athlon-64 3500+.