Need for Speed (postscript)

Jim Ault JimAultWins at yahoo.com
Mon Jul 16 16:14:08 EDT 2007


Thanks to both Mark and Jan.

> 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.
>  (full quote below)

This means appending the lines to the end of a file on disk, reading the
file back into a variable, then deleting the file on disk... is faster than
building the variable in RAM.

File writing is an area of Rev I use often, but only for small files.  I am
glad to know the comparisons/techniques so that I can improve my code.

For me, always using the "put var after url filepathname" meant I avoided
learning some of the advantages of using "open file, write, close file"

Since my large log file would be generated within the same app, the file
reference could be stored as a custom property for use by all of my handlers
and then doing a "close file" on quit could be executed at the end of the
day.

Looks like it would save RAM useage and boost speed.  This means that my
apps will soon be converted in case I forget to turn off my log files!

Jim Ault
Las Vegas

On 7/16/07 2:50 AM, "Mark Smith" <mark at maseurope.net> wrote:

> 
> 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_______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list