Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Launch Time profiler in Xcode11.

Launch Time profiler in Xcode11.

hayaishi
WWDC19 Recap at LINE
https://line.connpass.com/event/134346/

LINE Developers

June 25, 2019
Tweet

More Decks by LINE Developers

Other Decks in Technology

Transcript

  1. Launch Time - Profiler. • Initializing • Initializing - System

    interface Initialization ͜ͷύʔτͰ͸System SideͷॳظԽϓϩηεΛ෼ੳ͢Δ͜ͱ͕ Ͱ͖·͢ɻ
  2. Launch Time - Profiler. • Initializing - Static Runtime Initialization

    Objcͷ+loadͱ͍ͬͨॳظԽϓϩηεͷ෼ੳΛ͢Δ͜ͱ͕Ͱ͖ ·͢ɻ
  3. Launch Time - Profiler. • Launching - UIKit initialization •

    Launching - UIKit Scene Creation willFinishLaunchingWithOptions()͕࢝·Δલʹ࣮ߦ͞Εͨॲཧ Λ෼ੳ͢Δ͜ͱ͕Ͱ͖·͢ɻ
  4. Launch Time - Profiler. LINEͰͷ࣮ྫͰ͕͢ɺLaunch TimeϓϩϑΝΠϥͰ-100msͷແ ବͳॲཧΛൃݟ͢Δ͜ͱ͕Ͱ͖·ͨ͠ɻ private static func

    _localizedString(forKey key: String) -> String { - return NSLocalizedString(key, tableName: "{{tableName}}", bundle: ModuleBundle.bundle, comment: "") + return NSLocalizedString(key, tableName: "{{tableName}}", comment: "") }
  5. Metrics ಉ༷ͷىಈ࣌ؒ͸ҎԼͷίʔυͰ΋औಘՄೳͰ͢ɻ extension ProcessInfo { var uptime: TimeInterval { return

    AbsoluteTime(time: AbsoluteTime.now) - startedTime } private var startedTime: AbsoluteTime { let pid = processIdentifier var mib = [CTL_KERN, KERN_PROC, KERN_PROC_PID, pid] var info = kinfo_proc() var size = MemoryLayout.stride(ofValue: info) let status = sysctl(&mib, numericCast(mib.count), &info, &size, nil, 0) assert(status != -1) return AbsoluteTime(time: info.kp_proc.p_starttime) } } ... let launchTimeFromProcessStarted = ProcessInfo.processInfo.uptime * 1_000 print("\(launchTimeFromProcessStarted)ms") // got a similar as a Launch Time profile.
  6. Wrap Up • Xcode11ͰϓϩϑΝΠϧΛऔͬͯΈ·͠ΐ͏ɻ(࣮ػΛ࢖ͬͯ ͍ͩ͘͞) • Launch TimeϓϩϑΝΠϧ͸ىಈϓϩηεΛ༰қʹղੳՄೳ Ͱ͢ɻ •

    ύϑΥʔϚϯεΛվળ͢Δͱ͖͸ϓϩϑΝΠϧΛΈͯɺम ਖ਼ɺϓϩϑΝΠϧΛݟΔͷ܁Γฦ͠ɻ • Xcode11 Beta͸͢Ͱʹ͍͔ͭ͘ͷMetricsΛఏڙ͍ͯ͠·