Tip #8 in my Top 10 Performance Tips For 2012 was to reduce static accesses of variables, functions, etc. in favor of non-static variables and, especially, local variables. I neglected to reference one of my articles and it was pointed out to me that I hadn’t actually written such an article! So today I’ll elaborate on my tip and show why you should prefer non-static and local variables so you can find out just why it deserves its place as a top tip.
Posts Tagged static
Today’s article follows up on an article I wrote way back in August of 2009 about the order of operations when you use a class. In the original article I showed the order of field initializers and constructors. Today I’m expanding on that to show three more chunks of code that are run. Can you guess what those chunks are?
I was reminded about the flash.sampler API by Grant Skinner’s recent post about it. While only available in the debug player, it can still tell us some valuable information about what goes on in the release player. Today I’m using the getSize function to find out how much memory overhead various classes impose, even when they are empty.
With access specifiers, statics, plain functions, and overriding, there are a lot of ways you can dress up a function in AS3. But how many programmers really know the performance implications of these options? Read on to find a straightforward test showing just that. EDIT: added functions defined in interfaces, getters, setters, and final functions.