如何测量 OpenGL ES 的真实 FPS 性能? [英] How to measure true FPS performance of OpenGL ES?

查看:10
本文介绍了如何测量 OpenGL ES 的真实 FPS 性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到这是两个不同的东西:

I realized that these are two different things:

绘图,并将其显示在屏幕上.

Drawing, and getting it on screen.

因此,虽然您可以以 60 FPS 的速率从 CADisplayLink 进行每次调用,但如果您的绘图操作花费的时间略长于 1/60 秒,那么理论上您最终会得到 30 FPS,因为您错过了其他所有操作有机会通过渲染管道.

So while you may draw in every single call from CADisplayLink at a rate of 60 FPS, if your drawing operations take slightly longer than 1/60 seconds you end up with 30 FPS in theory, because you're missing out every other chance to get through the render pipeline.

好的;知道了这一点,记住开始 NSTimeInterval 并在运行循环中增加一个帧计数器,然后在结束时检查是否经过了一秒并计算最后经过的一秒的 FPS,这似乎是无稽之谈.

OK; Knowing this, it seems nonsense to remember the start NSTimeInterval and incrementing a frame counter in the run loop, then checking at the end if a second has passed and calculate the FPS for the last passed second.

我想要一种从屏幕上的 OpenGL ES 实际获取真正 FPS 值的方法.我查看了 Xcode 3.2.6 中的工具,但找不到适合的工具.但我记得有一种方法可以获得该 FPS 值.真实的.

I want a way to actually get the true FPS value from OpenGL ES on screen. I looked into instruments in Xcode 3.2.6 but couldn't find one for this. But I remember there was a way to get that FPS value. The real one.

怎么做?

推荐答案

通过帧率测量 OpenGL ES 性能 可能不是最好的方法.我已经开始自己记录帧时间,这似乎可以更准确地评估我的整体渲染性能.将您的渲染封装在类似

Measuring OpenGL ES performance by framerate may not be the best approach. I've taken to recording frame time myself, which seems to provide a more accurate assessment of my overall rendering performance. It's trivial to encapsulate your rendering in something like

CFTimeInterval previousTimestamp = CFAbsoluteTimeGetCurrent();

// Do your OpenGL ES frame rendering here, as well as presenting the onscreen render buffer

CFTimeInterval frameDuration = CFAbsoluteTimeGetCurrent() - previousTimestamp;
NSLog(@"Frame duration: %f ms", frameDuration * 1000.0);

获取渲染时间.如果你想要的话,你的瞬时帧率是上面代码中 frameDuration 的倒数.

to obtain rendering time. If you want it, your instantaneous framerate is the inverse of frameDuration in the above code.

注意对整个帧的渲染计时,因为 iOS 和其他移动设备中基于图块的延迟渲染器可能会通过延迟特定渲染操作直到帧被绘制到屏幕之前来隐藏特定渲染操作的真实成本.

Be careful to time the entire frame rendering, because the tile-based deferred renderer in iOS and other mobile devices may hide the true cost of particular rendering operations by delaying them until just before the frame is drawn to the screen.

但是,如果您想从 Instruments 获得不太精确的帧率,您可以使用 OpenGL ES Driver 工具来实现,该工具将每秒核心动画帧数报告为其记录的统计数据之一:

However, if you want to obtain a less precise framerate from Instruments, you can do that using the OpenGL ES Driver instrument, which reports Core Animation Frames Per Second as one of its logged statistics:

这篇关于如何测量 OpenGL ES 的真实 FPS 性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆