Skip to content

Instantly share code, notes, and snippets.

@leviathan
Created January 14, 2014 13:13
Show Gist options
  • Save leviathan/8418102 to your computer and use it in GitHub Desktop.
Save leviathan/8418102 to your computer and use it in GitHub Desktop.
UIKit Benchmarking Drawing
CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(refresh:)];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
counter = 0;
previousTimestamp = displayLink.timestamp;
- (void)refresh:(CADisplayLink *)displayLink {
counter++;
if (counter > 60) {
CGFloat timePerFrame = (displayLink.timestamp - previousTimestamp) / 60.0;
NSLog(@"Time per frame: %f", timePerFrame);
previousTimestamp = displayLink.timestamp;
counter = 0;
}
[self bringTheViewOnScreen];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment