efficiency testing local vs global variables
Posted: 23 May 2016 00:15
I wondered whether efficiency considerations regarding use of local vs. global variables could be neglected because of only minor differences of performance (= power drain), and put together this little flow to measure.
It's up to yourself to draw your own conclusions - here is the flow:
http://automagic4android.com/flow.php?i ... 6f55a45797
Surprised by the impact, I modified the flow towards assigning to variables only:
http://automagic4android.com/flow.php?i ... e3fd5151db
Now the same, but focusing on reading:
http://automagic4android.com/flow.php?i ... f8f3f2be28
It appeared that reading, then writing back to global variables is costly, but then I modified the second flow, to assign a non-literal and varying number:
http://automagic4android.com/flow.php?i ... b905341f29
My conclusions are not final, as it appears that more testing may be needed. My current impression is: writing to globals is expensive, reading is cheap (caching?), so in an attempt to improve performance, action script determines whether an assignment to a global actually modifies its value before writing it back.
It's up to yourself to draw your own conclusions - here is the flow:
http://automagic4android.com/flow.php?i ... 6f55a45797
Surprised by the impact, I modified the flow towards assigning to variables only:
http://automagic4android.com/flow.php?i ... e3fd5151db
Now the same, but focusing on reading:
http://automagic4android.com/flow.php?i ... f8f3f2be28
It appeared that reading, then writing back to global variables is costly, but then I modified the second flow, to assign a non-literal and varying number:
http://automagic4android.com/flow.php?i ... b905341f29
My conclusions are not final, as it appears that more testing may be needed. My current impression is: writing to globals is expensive, reading is cheap (caching?), so in an attempt to improve performance, action script determines whether an assignment to a global actually modifies its value before writing it back.