6

In my application, I've been working to get my fps above 60 in the core animation tool while scrolling my table views on an iPhone 5. My GPU isn't tapping out, and I couldn't really identify anything that sped it up (by commenting things out or deleting views in a nib).

After hours, I finally got curious and started a fresh junk application with nothing but a UITableViewController that just spits out the same cell over and over. I profiled this with 1000 rows while scrolling, and STILL only got in the high 50's.

What am I missing here? There's no way that's correct. It doesn't get any simpler than this straight up table displaying:

Table View

I uploaded a barebones app here.

Can someone confirm I'm not crazy?

Update

Is 60fps the max you can get on an iPhone? Will core animation ever go faster than that?

4

3 回答 3

8

几个想法:

  1. 我对此非常敏感,但在我看来,高 50 岁非常好。

  2. 当我使用代码(比 Instruments 更准确)对此进行基准测试时,iPhone 5 上的纯文本表格视图被锁定在 60.0 fps,所以我对你的“50 年代高”数字持怀疑态度。如果出现以下情况,您的表现可能会下降:

    • 如果您通过仪器测量它;

    • 您是否使用调试版本进行了测试;或者

    • 从 Xcode 启动应用程序,而不是从设备本身启动它。

  3. 为了对不同帧速率的 UX 有一些定性的感觉,我通过在我的表格视图的后台加载图像来慢慢降低性能,然后通过在前台执行这个计算成本高昂的过程进一步降低性能。我不会告诉你血腥的细节,但在我看来,50 年代中期及以上的帧速率都非常平滑,我开始注意到(但并不可怕)帧速率下降到 30 -40 fps,随着帧速率下降到 5-15 fps,UX 变得完全不可接受。您应该自己进行实验,但如果设计良好,应该能够保持在 50 年代的高位,但低至 50 年代中期可能就可以了。

  4. 仪器可能无法为您提供最准确的测量结果。我可能会用代码来衡量它。我在我的屏幕上放了fpsLabel一个备用位置,它每秒更新一次CADisplayLink(或者如果你有自定义绘制例程,你可以在那里进行自己的 fps 计算):

    @interface ViewController () <UITableViewDataSource>
    
    @property (nonatomic) CFTimeInterval previousTimestamp;
    @property (nonatomic) NSInteger frameCount;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        self.previousTimestamp = CFAbsoluteTimeGetCurrent();
    
        CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleDisplayLink:)];
        [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
    }
    
    - (void)handleDisplayLink:(CADisplayLink *)displayLink;
    {
        CFTimeInterval now = CFAbsoluteTimeGetCurrent();
        CFTimeInterval elapsed = now - self.previousTimestamp;
        self.frameCount++;
    
        if (elapsed > 1.0)
        {
            CGFloat fps = self.frameCount / elapsed;
            dispatch_async(dispatch_get_main_queue(), ^{
                self.fpsLabel.text = [NSString stringWithFormat:@"%.1f fps", fps];
            });
            self.previousTimestamp = now;
            self.frameCount = 0;
        }
    }
    

底线,在发布构建条件(即未链接到计算机,运行非调试构建)中更准确的测量(通过代码)的组合,我想你会发现 iPhone 5 上的表格视图性能非常好,锁定在 60 fps。但即使你的 UI 下降到 50 秒 fps,我个人认为这仍然没问题。

于 2013-02-14T07:13:11.350 回答
0

所以我认为这里的答案是我的期望是错误的。

我读到的所有内容似乎都在说你想让你的应用程序达到 60 fps。我没有意识到这实际上是最高 fps,而且你基本上永远不会获得稳定的 60fps。

在分析了仪器中的一堆其他应用程序(我没有意识到我可以在应用程序商店中的其他人的应用程序上做这些)之后,似乎大多数应用程序(大多数构建良好的应用程序)表视图在 50 的低到高徘徊时滚动。Path 是迄今为止我发现的一个例外,它几乎锁定在 59 或 60,这对于他们渲染的所有东西来说都是不可思议的。

所以看起来我实际上应该对 50+ fps 感到非常满意。

于 2013-02-14T07:10:50.127 回答
0

高于 60Hz 的动画只会浪费电池。屏幕刷新速度不会比这快,而且您的眼睛无法区分 60Hz 以上的运动。

于 2013-02-14T06:01:29.443 回答