由于我们是以编程方式讨论的,因此我不在考虑仪器.
一些参考预先列出:
根据文件,
The duration property provides the amount of time between frames. You
can use this value in your application to calculate the frame rate of
the display…
所以在我的演示项目中,我将一个displayLink添加到mainRunLoop,用于UITrackingRunLoopMode:
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(screenDidUpdated)];
[self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:UITrackingRunLoopMode];
并使用持续时间来计算FPS.但出乎我的意料,持续时间总是0.016667(~FPS 60),无论tableView顺利滚动还是不滚动.
我如何使tableView滞后是在 – (UITableViewCell *)tableView中添加一行:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath:
NSData *data = [NSData dataWithContentsOfURL:url];
然后我转向displayLink.timestamp,它工作正常.
2.观察drawRect:?
我的第二个想法是观察drawRect:,我想当tableView滚动时,它的drawRect:将被逐帧调用,然后我可以根据drawRect:callings之间的时间差来计算FPS.
但它失败了,导致drawRect:只被调用一次(而细胞多次).这种方式类似于使用CADisplayLink,但也许我选择了错误的位置/方法(如drawRect :)来观察,我可以观察任何推荐的方法吗?
问题:
>仪器如何准确测量FPS?
> doc是否表示使用持续时间来计算FPS错误?
>计算FPS的最佳方法是什么?
谢谢!