Situation:
I have a DAY structure. The DAY structure has three variables or attributes: a Date (NSString*), a Temperature (float), and a Rainfall (float).
Problem:
I will be iterating through an array of about 5000 DAY structures and graphing a portion of these onto the screen of the iPhone device using OpenGL.
Question:
As far as drawing performance, which is better? I could simply create an NSMutableArray of DAY structures (NSObjects) and iterate on the array on each draw call — which I think would be hard on the CPU. Or, I could instead manually manage three different C-Arrays — One for the Date String (2-Dimensional), One for the temperature (1-Dimensional) and One for the Rainfall (1-Dimensional). I could keep track of the current Day by referencing the current index of the iterated C-Arrays.
If it’s not a lot of work, always go with the convenient solution and only optimize when the code proves to be a bottleneck. And if you were going to write a big chunk of code that would take a long time to rewrite into a more optimized version, do a simple test case and profile.