Audio -- How much performance improvement can I expect from from reducing function calls by using buffers?
I'm working on an audio-intensive app for the iPhone. I'm currently calling a number of different functions for each sample I need to calculate. For example, I have an envelope class. When I calculate a sample, I do something like:
sampleValue = oscilator->tic() * envelope->tic();
But I could also do something like:
for(int i = 0; i < bufferLength; i++){
buffer[i] = oscilatorBuffer[i] * evelopeBuffer[i];
}
开发者_如何转开发
I know the second will be more efficient, but don't know by how much. Are function calls expensive enough that I'd be crazy not to use buffers if I care event a tiny bit about performance?
Just two thoughts:
- Function calls are very cheap.
- When talking about performance, nothing beats an experiment.
You could make all you current functions inline, and compare performance.
精彩评论