开发者

Canonical method of measuring iOS app startup performance?

I've been asked to reduce the startup time of an iOS application. I 开发者_如何学Cam 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


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);
});


Your method sounds like the correct one (I recommend using CFAbsoluteTime for your measurements).

One thing which may help you reduce the launch time is to avoid having View Controllers loaded from nibs on application launch. If I am not mistaken this forces them to be loaded into memory even before your app launches. Instead, alloc and init your view controllers dynamically when you need them. Note that you can still have the Views you'd like to be loaded by the view controllers stored in Nibs, you don't have to stop using IB. Just don't use IB to set static outlets for your app delegate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜