I'm not sure where this topic should go. It's definitely not a bug report nor a development ...
I try to call a sprite-local method with "Tell...".
The above script is 5-6 times slower than the exact equivalent below
The result defies common sense. Switching the context twice for "ask" and "tell" is faster than single "tell" with many blocks. Are there any optimizations for simple rings?
BTW: a call to the fastest sprite-local method is 10 times slower than the same method declared as global.
It's a long term concern about effective control structures.
I'm trying to achieve a kind of modularity and ordering using sprite-local methods. Some additional futures can be cleanly merged into a project just by importing sprite. Kind of user-level libraries without cluttering the global namespace, with additional benefits of maintaining and visualizing the state. Did You notice that edge mode behavior is based on the costume of EdgeMode sprite? It's kind of a joke but maybe can be worth noting as a DIY solution to global switches.
Backing to track - the 60 times performance penalty, for no apparent reason, for exactly the same amount of work needs some clarification.
@bh where is the proper place for such topics? I have some additional concerns about visibility issues with local methods and the detrimental effect of syncing with animation frames.
As I pointed out - the global if on edge,warp block doesn't have a parameter and doesn't use ask/tell - if you change it to my version - the performance difference is ONLY about 10 times
Yes, but it's not the point to slow down the fastest route, isn't it? And if the actual processing is done quite fast, 50-100 ms for 1000 iteration, passing parameters and "tell" can have reasonable overhead 60-100% not a few times.
Consider the worst case: single iteration took ~3 ms. The same work is done in 0.05ms by the local method.
Maybe I do something utterly wrong ...