我正在使用 opengl es iPhone 应用程序。计算应用程序每秒帧数以进行性能调整的最准确方法是什么?
最佳答案
我猜你想要的是这样的:
// fps calculation
static int m_nFps; // current FPS
static CFTimeInterval lastFrameStartTime;
static int m_nAverageFps; // the average FPS over 15 frames
static int m_nAverageFpsCounter;
static int m_nAverageFpsSum;
static UInt8* m_pRGBimage;
static void calcFps()
{
CFTimeInterval thisFrameStartTime = CFAbsoluteTimeGetCurrent();
float deltaTimeInSeconds = thisFrameStartTime - lastFrameStartTime;
m_nFps = (deltaTimeInSeconds == 0) ? 0: 1 / (deltaTimeInSeconds);
m_nAverageFpsCounter++;
m_nAverageFpsSum+=m_nFps;
if (m_nAverageFpsCounter >= 15) // calculate average FPS over 15 frames
{
m_nAverageFps = m_nAverageFpsSum/m_nAverageFpsCounter;
m_nAverageFpsCounter = 0;
m_nAverageFpsSum = 0;
}
lastFrameStartTime = thisFrameStartTime;
}
问候, 阿萨夫·皮哈西。
关于iphone - 计算 iphone 应用程序的 fps(每秒帧数),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1738315/