iphone - 计算 iphone 应用程序的 fps(每秒帧数)

标签 iphone opengl

我正在使用 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/

相关文章:

ios - iphone 5 和 6 的导航栏图像

ios - 在 TabViewController 和 NavigationController 之间导航

iphonesdk打印文档

c++ - 在 Opengl 中用球体绘制椭圆

iphone - 不使用drawrect方法获取UIView的Context

ios - SwiftUI - 如何模糊 View 的默认背景颜色?

c++ - 尝试使用 Assimp GLM 从 MD5 文件加载 OpenGL 中的动画

opengl - 在 OpenGL 中设置 mat4

C++ Opengl BMP 如何设法从 header 中提取宽度和高度?

macos - OpenGL 立方体未显示,可能有近平面和远平面吗?