zoukankan      html  css  js  c++  java
  • iOS应用启动时间

    转自:iOS 知识小集
    如果我们想知道程序启动的时间,则可以在工程的scheme中添加环境变量DYLD_PRINT_STATISTICS,如图1所示。这样在调试时,可以在控制台打印出程序启动过程中各个阶段所消耗的时间。

    图1

    我们运行程序就可以看到应用的启动时间,每个阶段的耗时。

    total time: 479.79 milliseconds (100.0%)
    total images loaded:  119
    total segments mapped: 454, into 42288 pages with 2946 pages pre-fetched
    total images loading time: 218.66 milliseconds (45.5%)
    total dtrace DOF registration time: 0.05 milliseconds (0.0%)
    total rebase fixups:  833,487
    total rebase fixups time: 75.39 milliseconds (15.7%)
    total binding fixups: 104,307
    total binding fixups time: 37.48 milliseconds (7.8%)
    total weak binding fixups time: 0.17 milliseconds (0.0%)
    total bindings lazily fixed up: 0 of 0
    total time in initializers and ObjC setup: 148.02 milliseconds (30.8%)
                             libSystem.dylib : 122.52 milliseconds (25.5%)
                 libBacktraceRecording.dylib : 2.78 milliseconds (0.5%)
                              libc++.1.dylib : 0.33 milliseconds (0.0%)
                              CoreFoundation : 2.65 milliseconds (0.5%)
                                   CFNetwork : 0.03 milliseconds (0.0%)
                                      vImage : 0.01 milliseconds (0.0%)
                      libLLVMContainer.dylib : 1.36 milliseconds (0.2%)
                            libGLImage.dylib : 0.12 milliseconds (0.0%)
                                  QuartzCore : 0.04 milliseconds (0.0%)
                libViewDebuggerSupport.dylib : 0.05 milliseconds (0.0%)
    total symbol trie searches:    48920
    total symbol table binary searches:    0
    total images defining weak symbols:  8
    total images using weak symbols:  31

    而且在iOS 10中,对输出的内容做了简化,如图2所示,简单易懂。这样,我们就可以有针对性去优化我们的启动流程。

    另外,如果嫌弃控制台输出的乱七八糟打印太多,可以在上面相同的位置添加OS_ACTIVITY_MODE ,value 设置为disable即可。

    参考

    WWDC 2016 406 Optimizing App Startup Time

    简化后的启动时间

  • 相关阅读:
    平衡二叉树之RB树
    平衡二叉树之AVL树
    实现哈希表
    LeetCode Median of Two Sorted Arrays
    LeetCode Minimum Window Substring
    LeetCode Interleaving String
    LeetCode Regular Expression Matching
    PAT 1087 All Roads Lead to Rome
    PAT 1086 Tree Traversals Again
    LeetCode Longest Palindromic Substring
  • 原文地址:https://www.cnblogs.com/wanghang/p/6298818.html
Copyright © 2011-2022 走看看