Stack Level Local/Globals

Dave Cragg dcragg at lacscentre.co.uk
Mon Jul 4 16:59:59 EDT 2005


On 4 Jul 2005, at 20:07, Eric Chatonet wrote:

> Hi Dennis,
>
> I agree since I provide many tools for the community that are made  
> to run in the IDE.

I agree too. :)

> So I never use globals but I prefer to refer to some custom  
> properties stored in specific custom property sets in my plugins or  
> in the revPreferences stack.
> BTW, I found that referring to custom properties is as fast as  
> using global variables and they don't vanish when they are stored  
> in revPreferences.
> That's great :-)

Eric, my own testing shows that accessing custom properties is  
significantly slower than accessing globals. (Over 20 times slower in  
a simple test.) When I have to refer to custom properties frequently  
(for example when going through hundreds of elements of a  
customPropertySet), I usually copy them to a variable first. But  
perhaps the access times vary by circumstances.

This was the most recent test I ran.

global gTest
on mouseUp
   set the cTest of me to 100
   put 100 into gTest
   put 100000 into tTimes
   put the milliseconds into tStart
   repeat tTimes
     get gTest
   end repeat
   put the milliseconds - tStart into tOut
   put the milliseconds into tStart
   repeat tTimes
     get the cTest of me
   end repeat
   put cr & the milliseconds - tStart after tOut
   put tOut
end mouseUp


>>
>> The stack global/local variable (I am not sure what it should be  
>> called) just has the scope of a single main-stack and sub-stacks.

How about just "stack variable"?

Cheers
Dave





More information about the use-livecode mailing list