Vamsi Anguluru

iOS Engineer

Swift Engineer

Games Developer

Vamsi Anguluru

iOS Engineer

Swift Engineer

Games Developer

Blog Post

Calculate Your App Launching Time

June 4, 2013 Uncategorized

Launching apps in a fraction of second is challenging. According to Apple’s documentation apps should be launched in less than 500 milliseconds and also apps that delay their launch more than 20  seconds will crash and go back to the home screen.
A global variable timer can be used to calculate app launching time,Use this code to log your app launching time to your debugger. 

//Appdelegate.h
CFAbsoluteTime StartTime;  
@interface AppDelegate : UIResponder <UIApplicationDelegate>

@end

//In your main.m start your timer
int main(int argc, char *argv[])
{
    StartTime = CFAbsoluteTimeGetCurrent();
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

//Finally in your AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    dispatch_async(dispatch_get_main_queue(), ^{
        NSLog(@"Launched in %f sec", CFAbsoluteTimeGetCurrent() - StartTime);
    });
.....
}
Write a comment