0

I've been trying to figure this out, people say 60fps but there is no solid evidence to this as far as I can tell?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
meds
  • 21,699
  • 37
  • 163
  • 314
  • 1
    BTW, the 60 fps target is discussed in [WWDC 2012 video, iOS App Performance: Graphics and Animations](https://developer.apple.com/videos/wwdc/2012/?id=238). – Rob Aug 04 '14 at 14:32

4 Answers4

4

You can create a display link (CADisplayLink) which will be called as the screen is updated.

Create some properties to keep track of the display link and variables to calculate the frame rate:

@property (nonatomic, strong) CADisplayLink *displayLink;
@property (nonatomic) CFTimeInterval startTime;
@property (nonatomic) NSInteger frameCount;

And you can then have methods to start, stop, and handle the display link:

- (void)startDisplayLink
{
    self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleDisplayLink:)];
    self.startTime = CACurrentMediaTime();
    [self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
}

- (void)stopDisplayLink
{
    [self.displayLink invalidate];
    self.displayLink = nil;
}

// This handler will update a label on the screen with the frame rate once per second

- (void)handleDisplayLink:(CADisplayLink *)displayLink
{
    self.frameCount++;

    CFTimeInterval now = CACurrentMediaTime();
    CFTimeInterval elapsed = now - self.startTime;

    if (elapsed >= 1.0) {
        CGFloat frameRate = self.frameCount / elapsed;

        // either, like below, update a label that you've added to the view or just log the rate to the console

        self.frameRateLabel.text = [NSString stringWithFormat:@"%.1f", frameRate];

        self.frameCount = 0;
        self.startTime = now;
    }
}

Then just start the display link (call startDisplayLink) and the above handler will report the calculated rate.

I personally prefer this to Instruments, because I find that Instruments itself impacts the performance more than the above code will (with Instruments your frame rates can appear lower than they really are). Clearly, this above code will also impact performance, but it's modest. Also, the above lets you measure the performance on a device untethered from your computer: You always should measure performance on a physical device rather than the simulator.

In answer to the question regarding the achieved frame rate, the above will illustrate that in simple animations, a frame rate of 60 fps is generally achieved, but the more complicated/numerous the animations are, the lower the achieved rate will be.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
2

Use Instruments to find out yourself, as it will depend on the app.

Droppy
  • 9,691
  • 1
  • 20
  • 27
0

Found this here:http://answers.unity3d.com/questions/32841/is-it-possible-to-get-above-30-fps-on-an-ios-devic.html

Yes- when you compile to xcode, look in the AppController.mm- there's a variable kFPS.

Set this to, say 60.

It's good practice I think to set it as high, so you have room to lower the cap.

Thereafter, be aware that 60fps games eat batteries for breakfast :)

jbutler483
  • 24,074
  • 9
  • 92
  • 145
  • This answer assumes the app is a Unity game - but the question doesn't mention anything to do with Unity or even if the app is a game or not. – Jasarien Aug 04 '14 at 13:38
  • Sorry, that was an assumption that they were asking for games. But it also suggests that 60FPS does work, although consumes a lot of power. – jbutler483 Aug 04 '14 at 13:43
  • 2
    All it proves is that Unity is able to run its graphics context at 60fps - it doesn't prove what FPS iOS UI animations run at or whether they're settable. Rob's answer discussing the display link is more appropriate as it measures the frame rate outside of a game context and how it is affected by iOS animation complexity. – Jasarien Aug 04 '14 at 13:51
-1

How about setting the output function in the view controller?:

 spriteView.showsFPS = YES;

Are we implying that the output value is not reliable?

Alex
  • 995
  • 12
  • 25