Version 1, last updated by rbencina at 25 Jan 05:19 UTC
Tips CPUUsage
Tips – CPU Usage
In many applications, it is important to keep the CPU usage to a minimum. Minimizing CPU usage may conflict with other objectives, such as minimizing latency, so it is up to you to decide which of these suggestions to use.
Here are some tips for things that might improve CPU performance:
- Use a high latency: Try using a large latency, which keeps lots of audio data buffered, so that the OS doesn’t need to constantly switch your audio app in and out of context. Of course, using too high a latency might cause cache misses, so you’ll have to experiment to see what’s best for your app.
- Use a large buffer size: If you are using small buffer sizes, try something larger. Most platforms do well with something in the 128-1024 range, and powers of two usually work well. Often, using paFramesPerBufferUnspecified will result in both good CPU performance and low latency, though this depends on the platform.
- Try platform specific flags: Some platforms offer special include files that offer platform specific features. For example, on Mac OS X, you can use the functions and constants in pa_mac_core.h to adjust sample-rate conversion settings and other things.