Key factors:----Instrument performance analysis artifact
1. Start-Up time
The application startup time is very important for the first experience of the user, while the system has strict requirements on the running time of the application startup and recovery, and the system shuts down the application directly when the application time-out. Here are a few common scenarios in which the system requires app uptime: * Launch 20 seconds Resume 10 seconds Suspend 10 seconds Quit 6 seconds background Task 10 minutes
The simplest way to get an accurate app startup time is to first add the following code to the MAIN.C:
123 |
CFAbsoluteTime StartTime;int main(int argc, char **argv) { StartTime = CFAbsoluteTimeGetCurrent();
|
Then add in the callback method of the Appdelegate application:didFinishLaunchingWithOptions :
dispatch_async(dispatch_get_main_queue(), ^{ NSLog(@”Lauched in %f seconds.”, (CFAbsoluteTimeGetCurrent() – StartTime)); });可能你会觉得为什么这样可拿到系统启动的时间,因为这个dispatch_async中提交的工作会在app主线程启动后的下一个run lopp中运行,此时app已经完成了载入并且将要显示第一帧画面,也就是系统会运行到`-[UIApplication _reportAppLaunchFinished]`之前。是用Instruments工具Time Profiler跑的调用栈,Instruments的使用方法建议看WWDC中与performance相关的[session录像](https://developer.apple.com/videos/wwdc),文字写起来太单薄不够直观哈。
2. User response
3. Memory
4. Graphic drawings
5. Documents
6. Network
APP Performance Analysis