I'm working at the audio buffer level, mixing audio signals created by a colleciton of objects. Since I'm looping through these objects at 44.1khz, efficiency is crucial. Is there any difference in the efficiency of iterating over an NSArray vs a C array of pointers? How about NSMutableArray?
Is there any difference in the efficiency of iterating over an NSArray vs a C array of pointers?
Yes. Iterating directly over a C array will be faster.
Most apps don't need to worry about this and should look elsewhere for performance gains. But if, in your app, this function runs 44,100 times per second, you probably should micro-optimize it (after, of course, making sure that it does as little as possible—that is, only the things you absolutely need to do 44,100 times per second).
How about NSMutableArray?
Vs. an NSArray? No difference that you can rely on or should care about.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With