nStart = Seconds() lnLoop = 1024*15 lnSize = 1024 lcString = "" For t=0 to lnLoop-1 lcString = lcString + Replicate("A",lnSize) Endfor ? Seconds()-nStartOn my computer this program runs for 409 seconds which is almost 7 minutes. On the other hand, the following program does exactly the same, but it finishes in 0.731 seconds. The actually string assembling is actually only 0.281. The rest of the time is what it takes VFP to copy the result into a string variable.
Declare Long GetProcessHeap in Win32API Declare Long HeapAlloc in Win32API Long, Long, Long Declare memcpy in NTDLL.Dll as memcpy_write Long, String@, Long Declare Long HeapFree in Win32API Long, Long, Long nStart = Seconds() lnLoop = 1024*15 lnSize = 1024 lnAddress = HeapAlloc( GetProcessHeap(), 0, lnLoop*lnSize ) For t=0 to lnLoop-1 memcpy_write( lnAddress+(t*lnSize), Replicate("A",lnSize), lnSize ) Endfor ? Seconds()-nStart lcString = Sys(2600, lnAddress, lnLoop*lnSize ) HeapFree( GetProcessHeap(), 0, lnAddress ) ? Seconds()-nStartChristof