I have been programming Java for Android for some time. Since performance is very important for the things I'm working on, I end up just spamming global variables. I guess everyone will come by now and tell me that this is the worst style in history, but let's keep it simple. For Android, local variables mean garbage collection and garbage collection - this is what kills performance.
Recently, I started using NDK. Now I feel like actually taking all the local variables and changing them to global variables. I am wondering if that makes sense in c code. Obviously, this is not a good style, but if it is necessary for speed, I will readily sacrifice the style.
I looked at old threads about local and global, but I could not find anything about speed. So my question is that if I call a function very often, is it because local variables are created and die after the function is executed? Or it doesn’t matter at all, and I can happily continue to use local variables.
I would have experienced it myself, but for some reason, the performance of my application rises and falls, like on a roller coaster, and I doubt that I can really understand the meaning of the data. I hope someone can help me before I rewrote the whole code :)
performance c android-ndk
Pandoro
source share