gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 21:17:15 28 4
gpt4 key购买 nike

我目前正在开发一个 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com