Kev*_* L. 6 iphone optimization
I am in the process of optimizing an iPhone app for very short load time and am wondering:
Is there a means of measuring the load time of an iPhone app from the time the user taps the icon to the time that the app is usable (or at least –viewDidLoad gets called)?
Ideally this would work in the device and simulator, but if someone has found a way to measure this time exclusively in the simulator that would at least be a starting point.
And no; "stopwatch" or "one Mississippi, two Mississippi" do not count. :-)
在 App Delegate 的 init 方法中启动一个计时器,然后在 viewDidAppear 时停止:-
启动计时器:-
NSDate *startTime = [NSDate date];
Run Code Online (Sandbox Code Playgroud)
...并以以下内容结尾:-
NSTimeInterval elapsedTime = [startTime timeIntervalSinceNow];
NSLog(@"Startup tasks: %f", -elapsedTime);
Run Code Online (Sandbox Code Playgroud)
这不会从点击图标的那一刻开始,但应该在您工作的相当早的时候开始。您可能可以在调试器控制台中输出的日志中查看较早的时间?