I’ve cracked a problem for several days now when it lists file names that exceed the Windows limit MAX_PATH. I am using Visual Studio 2008 with all the fixes that I can find. Timing is done with QueryPerformanceCounter and the company.
The last problem occurs in the following code:
start = getTime();
for( vector<wstring>::iterator it = files.begin(); it != files.end(); ++it )
{
#if USE_COUT
wcout << setw( 6 ) << it->length() << L": " << *it << endl;
#else
wstring x( *it );
wprintf( L"%6.6d: %s\n", it->length(), x.c_str() );
#endif
}
stop = getTime();
The above loop executes on a vector with 6755 elements with an average string length of 256 characters.
The code that prints through wcout takes approximately 52 seconds to display the vector using the loop above. Code that uses wprintf fingerprints after about 1.2 seconds.
If I minimize the console window, the printf code will work after about 500 milliseconds, and the wcout code will still take about 40 seconds.
iostreams , ... . 1993/1994 Borland OS/2 , 4 6 , stream, 200 sprintf.
, iostreams?
Edit:All of this flushing talk is curious to me.Is the \nline printffunctionally the same as std::endl, in the sense that both causes output a new line and stream for output?IIRC, printfwithout \nnot printing on any OS until the buffer is full or the stream is cleared, including Windows in the past.So, if wprintf( "%6.6d: %s\n", length, string )reset using \n, why wprintfnot as slow as wcout?Thanks for your feedback / opinions. It is a pity that I had it this way 18 years ago when I started to crack this material.
source
share