If you re-read the report, they were not "creating a 1MB string in memory", 
they were concatenating thousands of sub-strings until they had 1 MB.  It's the 
concatenation implementation that took all the time, because each instance 
allocated new memory space, did the concat, then released the old memory.

I ran into this some years ago, when a colleague had a VFP program that was 
running very slowly.  The problem was the same; he was generating a small piece 
of output text, concatenating it to what he already had, then generating the 
next piece, etc.  The solution was to generate all the pieces in an array, then 
do one big concat.

I suspect it was the malloc that was the culprit, not the concat.

Dan

----------------------------------------
> Date: Sat, 28 Mar 2015 09:46:57 +0000
> Subject: Re: [NF] its-not-always-quicker-to-do-things-in-memory
> From: trukke...@gmail.com
> To: profoxt...@leafe.com
>
> Interesting. It's certainly faster on my box (VFP9 SP2 on XP SP3) to create
> a 1 Mb string in memory and do one write than to do 1,000,000 calls to
> STRTOFILE(<string>, <file>,1). In memory took about 690 ms, the other
> method took over 10 secs to do 7000 writes.

                                          
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/bay169-w9131555ca866aa92b798b28a...@phx.gbl
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to