Albert,
I didn't try strstream, I didn't know that would keep the whole 100k string available. I did try fixing the CString buffer size it doesn't change the performance much at all.
FWIW bagging the CString and replacing it a more special case (i.e. predefined buffer size char)
int CStrtestdllApp::test3()
{
char cTest[100100];
char *ap;
ap = cTest;
int i;
clock_t tStart;
tStart = clock();
for ( i = 0; i < 10000; i++ )
{
sprintf( ap, "%10d", i );
ap += 10;
}
tStart = ( clock() - tStart );
return (int)tStart;
}
And the code executes in 0.05 seconds, on par with the VFP6 code.
>Compared to VFP 5.0a, the C++ takes aprox. half the time. See how VFP 6.0 fairs.
>
>The C++ io stream classes are capable of doing easy formatting much more flexibly than the old C stdio functions.
>
>This example could be faster if the max size of the string were set so dynamic memory allocation is not necessary.