seed of setProp vs local vars vs globals
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
seed of setProp vs local vars vs globals
Hello,
I am working on a custom video player controller, which offers the basic functions of the standard controller of the player object but adds functions my project needs.
This is the first time I used setProp/getProp to set the parameters of my custom control.
Now I wonder whether this was a wise, as I have the subjective impression setProp/getProp might execute slower than using local vars and accessor functions and/or global vars.
Any advice?
Thanks,
Olli.
I am working on a custom video player controller, which offers the basic functions of the standard controller of the player object but adds functions my project needs.
This is the first time I used setProp/getProp to set the parameters of my custom control.
Now I wonder whether this was a wise, as I have the subjective impression setProp/getProp might execute slower than using local vars and accessor functions and/or global vars.
Any advice?
Thanks,
Olli.
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: seed of setProp vs local vars vs globals
Hi.
Not sure what you mean by speed issues. Those control structures are triggered by changes in (or queries of) custom properties. They are essentially "handler" names that receive a "message" derived from such actions.
But once "trapped", LC takes over. The only thing to watch is recursion.
Or do I have your question totally wrong?
Craig Newman
Not sure what you mean by speed issues. Those control structures are triggered by changes in (or queries of) custom properties. They are essentially "handler" names that receive a "message" derived from such actions.
But once "trapped", LC takes over. The only thing to watch is recursion.
Or do I have your question totally wrong?
Craig Newman
Re: seed of setProp vs local vars vs globals
Hello: sorry for not being clear enough.
My understanding is as follows: if i set a custom property using syntax "set the cMyProperty to tValue" it will trigger a cMyProperty message that will be captured by the setProp handler "setProp cMyProperty".
If I would use a local variable/accessor functions, i would use the syntax "set_MyProperty tValue", which will lead to the activation of handler "on set_myProperty pVal".
Finally, I could use global vars, and then I would use the syntax "put tValue into gMyProperty".
Thus, I wonder whether one of these methods takes less time to execute.
olli.
My understanding is as follows: if i set a custom property using syntax "set the cMyProperty to tValue" it will trigger a cMyProperty message that will be captured by the setProp handler "setProp cMyProperty".
If I would use a local variable/accessor functions, i would use the syntax "set_MyProperty tValue", which will lead to the activation of handler "on set_myProperty pVal".
Finally, I could use global vars, and then I would use the syntax "put tValue into gMyProperty".
Thus, I wonder whether one of these methods takes less time to execute.
olli.
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: seed of setProp vs local vars vs globals
The speed difference is probably best measured in microseconds, and since in this case it's in response to a user action any difference won't be noticeable. I'd just use whichever works most logically for your setup. If those values are effectively properties for the controller, using custom properties would be a natural fit.
If you want to measure the differences yourself, these tips on benchmarking may be helpful:
http://livecodejournal.com/tutorials/be ... vtalk.html
If you want to measure the differences yourself, these tips on benchmarking may be helpful:
http://livecodejournal.com/tutorials/be ... vtalk.html
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: seed of setProp vs local vars vs globals
Ah.
Variables are a bit faster. Though I bet it will not make a difference. In a button script:
Craig
Variables are a bit faster. Though I bet it will not make a difference. In a button script:
Code: Select all
on mouseUp
put the ticks into temp
repeat 1000000
get the tprop of me
end repeat
answer the ticks - temp
put the ticks into temp
repeat 1000000
dothis
end repeat
answer the ticks - temp
end mouseUp
on dothis
end dothis
getProp tProp
end tProp
Re: seed of setProp vs local vars vs globals
Thank you all for your help. I'll stick with the current design then, which was based on the data structure design. Olli.