Need for Speed (postscript)

Mark Smith mark at maseurope.net
Mon Jul 16 04:50:43 CDT 2007


On 16 Jul 2007, at 07:26, Jim Ault wrote:

> On 7/15/07 8:37 PM, "Ludovic Thébault"  
> <ludovic.thebault at laposte.net> wrote:
>
>> On Sun, 15 Jul 2007 20:58:32 +0100, Beynon, Rob wrote:
>>
>> Hello, try to append the result to a file, it's a lot faster :
>
> Caution:  My limited experience with appending to log files is that  
> the
> larger the file size, the slower the append.

I guess this must have to do with how much RAM is available vs how  
much disc space is needed.

I just did this benchmark (with some nonce data):

on toFile
   put  
"10000,10001,10002,10003,10004,10005,10006,10007,10008,10009,100010"  
into tStr
   put the tempName into tFile
   open file tFile for append
   set cursor to watch
   put the millisecs into tStart

   repeat 1000000
     write tStr & cr to file tFile
   end repeat
   close file tFile
   put URL ("file:" & tFile) into tOutput
   delete file tFile
   put the millisecs - tStart
end toFile

on toVariable
   put  
"10000,10001,10002,10003,10004,10005,10006,10007,10008,10009,100010"  
into tStr
   set cursor to watch

   put the millisecs into tStart

   repeat 1000000
     put tStr & cr after tOutput
   end repeat

   put the millisecs - tStart
end toVariable

tOutput ends up at 67MB in both cases, and 'toFile' took just over 5  
seconds, whereas 'toVariable' took just over 40 seconds.
This is on a Mac PBG4 with 768MB RAM.

This could be useful to know when building up large lists.

Best,

Mark


More information about the use-livecode mailing list