Do multiple substacks slow down a program?
Eric Chatonet
eric.chatonet at sosmartsoftware.com
Wed Aug 24 11:18:59 EDT 2005
Hi Steve,
We are "anthropomorphic thinkers" and assume that a substack is "far"
from another substack or a mainstack :-)
But all data are in RAM and as far I know you are unable to notice a
*practical* significant difference in most cases (depends of the
amount of data).
For instance, you have a custom property in stack A and the same
custom property in a substack B from stack A.
From stack A you retrieve the contents of the custom property in
stack A (the same one) and in substack B.
You will find that retrieving the custom property contents from stack
A is about 10% faster than from its substack B.
This seems "important" but in order to notice this difference you
will have to run a loop 1000 times...
So, if speed is *very important* and the data you want to process are
heavy (that's the point able to make the difference), the answer is:
place the data in the stack that uses these data.
But in most cases, retrieving data from a substack to process them in
the mainstack will not be noticeable.
More, if the data used by a mainstack are scattered in many
substacks, this will not change anything :-)
So, if it is your case, give priority to your architecture.
Note that if you retrieve the same data from another stack (not a
substack), then the time will increase about 25%.
Here is the handler I used to perform a test:
constant kTimes = 1000
on mouseUp
put the milliseconds into tStart
repeat kTimes
get the cBuiltInColors of this stack
end repeat
put the milliseconds - tStart into tThisStackTime
-----
put the milliseconds into tStart
repeat kTimes
get the cBuiltInColors of stack "Sub"
end repeat
put "Substack:" && the milliseconds - tStart & cr \
& "This stack:" && tThisStackTime
end mouseUp
The cBuiltInColors custom property was 4 lines:
blue
brown
darkorange
red
Result for 1000 loops (weighted by 100 runs):
Substack: 20 milliseconds
This stack: 18 milliseconds
Best Regards from Paris,
Eric Chatonet.
Le 24 août 05 à 16:10, Stgoldberg at aol.com a écrit :
> So far I'm running close to 100% success with advice received
> from this
> forum and am very grateful for that. One more question: I'm
> planning a program
> that uses one or more substacks. The question is whether to place
> all the key
> data into one substack or to divide them into 2 or more
> substacks. One the
> one hand, dividing into separate stacks keeps everything neatly
> arranged.
> However, does it slow down the speed of a program if scripting
> commands go from
> one substack to another, as opposed to remaining confined to one
> substack?
> Thanks.
> Steve Goldberg
----------------------------------------------------------------
So Smart Software
For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch
Free plugins and tutorials on my website
----------------------------------------------------------------
Web site http://www.sosmartsoftware.com/
Email eric.chatonet at sosmartsoftware.com/
Phone 33 (0)1 43 31 77 62
Mobile 33 (0)6 20 74 50 86
----------------------------------------------------------------
More information about the use-livecode
mailing list