Bob,
On my P2-300 64meg this code:
LOCAL cstr, lnow, lnow2
cstr = ''
lnow = seconds()
FOR i = 1 to 10000
cstr = cstr + str(I)
endfor
? seconds() - lNow
VFP5 takes an average of 7.2 seconds to execute. VFP6 averages an amazing 0.060 seconds! Testing this in more detail show the vast performance improvement is in the string concatenation part of the VFP code.
For the heck of it I created a DLL in VC++ because string handling is much faster in C++. This is the code:
int CStrtestdllApp::test1()
{
CString cTest;
cTest = "";
int i;
clock_t tStart;
char cBuffer[11];
tStart = clock();
for ( i = 0; i < 10000; i++ )
{
sprintf( cBuffer, "%10d", i );
cTest = cTest + cBuffer;
}
tStart = clock() - tStart;
return (int)tStart;
}
And called it from VFP the C++ code took an average of 4.8 seconds.
I think the boys over in the C++ team should go borrow some code from the VFP team! *BG*
>
>VFP:
> I did a little more and added an edit box and a command button to start the comparison. Here is the code in the click of the command button. The VFP code actually has to do more by updating the edit box but let's ignore that.
>
>LOCAL cstr, lnow, lnow2
>cstr = ''
>
>lnow = seconds()
>FOR i = 1 to 10000
> cstr = cstr + str(I)
>endfor
>
> thisform.edit1.value = cstr
>lnow2 = seconds()
>wait window str(lnow2 - lnow, 9, 6)
>
>
>Results:
>I saved these for the end. On my PC (P-150 64 MB) the VB 5 code took 17.18 seconds. The VFP 6 code took 0.315 seconds. I would call that substantially better performance. When I boosted the counter to 100000 VFP took only 3.397 seconds. I couldn't test VB 5 because even at 30000 the process stopped responding and I had to Ctl-Alt-Delete to kill it. Maybe it was just afraid to answer.
>
>While this may be a totally useless exercise I had great fun with it yesterday. One of the VB'ers here tested it with 6.0, p-code vs native code etc. Admittedly VB 6 is faster than VB 5. It is only 12 - 15 times slower that VFP 6 rather than 50 times slower.