Local variable is 20 times more efficient than a global one

When counting from 1 to 20,000 using a variable, the time it takes:

1.If run in ai2 companion, it's around 8 times difference
2.But if run in apk, it's more than 20 times!!! See below↓

variable_test.aia (2.9 KB)

That is, if my app contains a large quantity of caculating, i should aways copy the global variable to a local one, after caculating, then return the result to the global varieble :neutral_face:

3 Likes

Interesting, my tests, using your example, global took @ 10x as long (700ms vs 7000ms)

1 Like

yes the difference in efficiency is huge. wow

When it comes to speed, locality rules.

This applies from the chip level to the server level.

1 Like

When it comes to speed, Assembly rules. :grin:

2 Likes

Cash is King - Investopedia
Cache is king - Intel

3 Likes