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

Measuring Performance Using Logging / 20180619 ...

Measuring Performance Using Logging / 20180619 #roppongiswift

ROPPONGI.swift 第4回 WWDC振り返り会(VISITS・Origami共催) - connpass
https://visits.connpass.com/event/90254/
の発表資料です。

# 参考リンク

Measuring Performance Using Logging - WWDC 2018 - Videos - Apple Developer
https://developer.apple.com/videos/play/wwdc2018/405/

takasek

June 19, 2018
Tweet

More Decks by takasek

Other Decks in Programming

Transcript

  1. import os.signpost let refreshLog = OSLog( // ! subsystem: "com.example.your-app",

    category: "RefreshOperations" ) for element in panel.elements { fetchAsset(for: element) } 10
  2. import os.signpost let refreshLog = OSLog( subsystem: "com.example.your-app", category: "RefreshOperations"

    ) for element in panel.elements { os_signpost(type: .begin, log: refreshLog, // name: " " ") fetchAsset(for: element) os_signpost(type: .end, log: refreshLog, // name: " " ") } 11
  3. for element in panel.elements { os_signpost(type: .begin, log: refreshLog, name:

    " ") fetchAsset(for: element) os_signpost(type: .end, log: refreshLog, name: " ") } 13
  4. os_signpost(type: .begin, log: refreshLog, name: " ") // for element

    in panel.elements { os_signpost(type: .begin, log: refreshLog, name: " ") fetchAsset(for: element) os_signpost(type: .end, log: refreshLog, name: " ") } os_signpost(type: .end, log: refreshLog, name: " ") // 14
  5. os_signpost(type: .begin, log: refreshLog, name: " ") for element in

    panel.elements { os_signpost(type: .begin, log: refreshLog, name: " ") fetchAssetAsync(for: element) { os_signpost(type: .end, log: refreshLog, name: " ") } } notifyWhenDone { os_signpost(type: .end, log: refreshLog, name: " ") } 16
  6. let !♻ = OSSignpostID(log: refreshLog) // os_signpost(type: .begin, log: refreshLog,

    name: " ") for element in panel.elements { let !$ = OSSignpostID(log: refreshLog, object: element) // os_signpost(type: .begin, log: refreshLog, name: " ") fetchAssetAsync(for: element) { os_signpost(type: .end, log: refreshLog, name: " ") } } notifyWhenDone { os_signpost(type: .end, log: refreshLog, name: " ") } 17
  7. let !♻ = OSSignpostID(log: refreshLog) os_signpost(type: .begin, log: refreshLog, name:

    " ", signpostID: !♻ ) // # for element in panel.elements { let !$ = OSSignpostID(log: refreshLog, object: element) os_signpost(type: .begin, log: refreshLog, name: " ", signpostID: !$ ) // # fetchAssetAsync(for: element) { os_signpost(type: .end, log: refreshLog, name: " ", signpostID: !$ ) // # } } notifyWhenDone { os_signpost(type: .end, log: refreshLog, name: " ", signpostID: !♻ ) // # } 18
  8. Example Represents Log category "RefreshOperatio ns" ؔ࿈͢Δॲཧͷ ·ͱ·Γ Signpost name

    "!" ܭଌର৅ Signpost ID "! ܭଌ͢Δॲཧ ͻͱͭͻͱͭ 19
  9. os_signpost( type: .begin, log: log, name: "Compute Physics", "for %{public}@

    at (%.1f, %.1f)" + "with mass %.2f and velocity (%.1f, %.1f)", description, x1, y1, m, x2, y2 ) • %.1f , %.2f , %d ... • %{public}@ • %{xcode:size-in-bytes}llu • Instrumentsʹ෼ੳσʔλͱͯ͠ೝࣝͤ͞Δ 21
  10. let refreshLog: OSLog if ProcessInfo.processInfo.environment.keys.contains("SIGNPOSTS_FOR_REFRESH") { refreshLog = OSLog( subsystem:

    "com.example.your-app", category: "RefreshOperations" ) } else { refreshLog = .disabled } 25
  11. • Instruments → Blank → [+] → "os_signpost" ͰϑΟϧλ •

    signposts͕֬ೝͰ͖Δʢ˞࣮ػͰಈ͔͢͜ͱʣ • Time Profiler • ͰΠϕϯτΛ֬ೝͰ͖ΔOSLog΋͋Δ • OSLog(subsystem: ..., category: .pointsOfInterest) ʹ .event ΛૹΔ • Custom Instruments • ϏδϡΞϥΠζͷํ๏ΛΧελϚΠζͰ͖Δ • ʮnඵҎ্͔͔͍ͬͯΔॲཧΛ੺͘දࣔ͢Δʯͱ͔ 28