Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Canonical method of measuring iOS app startup performance?

I've been asked to reduce the startup time of an iOS application. I am very familiar with the platform/tools in general but I haven't focussed upon application startup time before. I'm wondering if there are known patterns for attacking this problem?

I realize that I can simply measure the time it takes to go from main() through the completion of application:didFinishLaunchingWithOptions: (which includes any background loading tasks), but again, I am hoping there might be a more standardized way to do this.

Any suggestions would be greatly appreciated!

-M

like image 856
Matty P Avatar asked Sep 17 '11 14:09

Matty P


1 Answers

from WWDC 2012 session 235

set the start point at the first line of code in main.m

#import <UIKit/UIKit.h>

CFAbsoluteTime StartTime;

int main(int argc, char *argv[])
{
    StartTime = CFAbsoluteTimeGetCurrent();

    @autoreleasepool {
        ...

set the end point somewhere in AppDelegate's application:didFinishLaunchingWithOptions:

extern CFAbsoluteTime StartTime;
 ...
dispatch_async(dispatch_get_main_queue(), ^{
    NSLog(@"Launched in %f sec", CFAbsoluteTimeGetCurrent() - StartTime);
});
like image 187
Gon Avatar answered Oct 01 '22 09:10

Gon