iphone - 如何查看 iPhone 应用程序的启动时间?

标签 iphone ipad ios5

我目前正在开发一个 iOS 应用程序。我需要比较 iPhone 和/或 iPad 上的启动时间。有人可以建议一下吗?

最佳答案

记下 main()-application:didFinishLaunchingWithOptions: 中的当前时间,然后计算差值。示例:

main.m:

// main.m

NSDate *startupDate;

int main(int argc, char **argv)
{
    NSAutoreleasePool *pool = [NSAutoreleasePool new];
    startupDate = [[NSDate alloc] init];
    int exitCode = UIApplicationMain(argc, argv, NULL, @"AppDelegate");
    [startupDate release];
    [pool drain];
    return exitCode;
}

// etc.

AppDelegate.m:

// AppDelegate.m

extern NSDate *startupDate;

- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)opts
{
    NSDate *launchFinishedDate = [[NSDate alloc] init];
    NSTimeInterval launchTimeInSeconds = [launchFinishedDate timeIntervalSinceDate:startupDate];
    [launchFinishedDate release];

    // launchTimeInSeconds will contain the launch time in seconds (floating point).
    // create UI setup etc. as usual
}

关于iphone - 如何查看 iPhone 应用程序的启动时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10402932/

相关文章:

ios - 没有已知的选择器混淆类方法

ios - 证书尚未生效

ios - 通过 segue 传回 NSNumber

iphone - 带有 TextField 的 UITableViewCell 并检查输入

ios - 将 PDF 文件保存到 iBooks。

iphone - 使用CLLocationDistance计算最外层坐标?

iOS:使用全屏图像构建幻灯片

ios - 如何在 iOS 中查找选定的文本字段

objective-c - XMPP 不适用于 iOS 4.3 项目

objective-c - 核心数据 : Freeze at the end of a save