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

カスタムInstrumentsでアプリをピカピカに!

Chiharu Nameki
September 07, 2019

 カスタムInstrumentsでアプリをピカピカに!

Instrumentsの基本
OSSignposts
カスタムInstrumentsの作成
活用事例
CLIPSによるModelerの自作

Sample Code
https://github.com/Ridwy/iosdc19-custom-instruments

Chiharu Nameki

September 07, 2019
Tweet

More Decks by Chiharu Nameki

Other Decks in Technology

Transcript

  1. Command Line࣮ߦ ޙ͔Β݁ՌΛΈΔέʔε ̍ $instruments -t "Allocations" -l 10000 -D

    SaveFileName.trace PathToYourApp ςϯϓϨʔτ ه࿥࣌ؒ(ϛϦඵ) อଘઌ ଌఆର৅
  2. let spid = OSSignpostID(log: logHandle) os_signpost(.begin, log: logHandle, name: "Scene

    Detection”, signpostID: spid, "url: %{public}s", urlString) os_signpost(.end, log: logHandle, name: "Scene Detection”, signpostID: spid, "count: %d", sceneCount) detector.start(url: url) { } // ඇಉظॲཧ • .beginͱ.endͰғΉ • ରԠؔ܎͸ಉ͡OSSignpostIDΛ౉͢͜ͱͰ୲อ Interval os_signpost()ΛίʔυʹຒΊࠐΉ
  3. ϨίʔσΟϯάதͰͳ͍ͱ͖ͷ ίʔυͷ࣮ߦʹΠϯύΫτΛ༩͑ͳ͍Α͏ʹ஫ҙ os_signpost(.event, log: logHandle, name: “Seek”, "to: %f", marker.startTime.seconds)

    NG ͕͜͜ධՁ͞Εͯ͠·͏ if OSLogHandle.pointsOfInterest.signpostsEnabled { let seekTime = marker.startTime.seconds os_signpost(.event, log: logHandle, name: “Seek", “to: %f", seekTime) } // ϨίʔσΟϯάதͷΈ࣮ߦ͞ΕΔ OK
  4. Instruments Architecture Data Stream Table Modeler Table Standard UI Signposts,

    ktraceͳͲͷσʔλͷιʔε Data Stream Table σʔλͷೖΕ෺ɼܕ͸εΩʔϚͰఆٛ Modeler ೖྗσʔλΛධՁͯ͠ग़ྗσʔλΛੜ੒ Standard UI InstrumentsΞϓϦͷUI
  5. εΩʔϚΛهड़͢ΔͨΊͷXMLཁૉ XML Element Automatic Modeler Memo <point-schema> <interval-schema> <os-log-point-schema> ◦

    <os-signpost-point-schema> ◦ Xcode 11~ <os-signpost-interval-schema> ◦ Automatic Modeler = ModelerΛࣗಈੜ੒ͯ͘͠ΕΔػೳ os_signpost΍os_log͔Βఆٛ͞ΕͨεΩʔϚʹม׵ʂ
  6. <?xml version="1.0" encoding="UTF-8" ?> <package> <id>jp.co.chiharu-nameki.ScenePlayerBehavior</id> <title>ScenePlayerBehavior</title> <owner> <name>Chiharu Nameki</name>

    </owner> <import-schema>os-signpost</import-schema> <os-signpost-interval-schema> <id>scene-detection</id> <title>Scene Detection</title> <subsystem>"jp.co.chiharu-nameki.ScenePlayer"</subsystem> <category>"Behavior"</category> <name>"Scene Detection"</name> <start-pattern> <message>"url: " ?url</message> </start-pattern> <end-pattern> <message>"count: " ?count</message> </end-pattern> <column> <mnemonic>url</mnemonic> <title>Video URL</title> <type>string</type> <expression>?url</expression> </column> <column> <mnemonic>scene-count</mnemonic> <title>Scene Count</title> <type>uint32</type> <expression>?count</expression> </column> <column> <mnemonic>result-color</mnemonic> <title>Color</title> <type>event-concept</type> <expression>(if (= ?count 0) then "Red" else "Green")</expression> </column> </os-signpost-interval-schema> <instrument> <id>jp.co.chiharu-nameki.ScenePlayerBehavior.ScenePlayerBehavior</id> <title>ScenePlayer Behavior</title> <category>Behavior</category> <purpose>Visualize what's happen in ScenePlayer app</purpose> <icon>Points of Interest</icon> <create-table> <id>user-actions</id> <schema-ref>os-signpost</schema-ref> <attribute> <name>subsystem</name> <string>jp.co.chiharu-nameki.ScenePlayer</string> </attribute> <attribute> <name>category</name> <string>UserAction</string> </attribute> </create-table> <create-table> <id>scene-detections</id> <schema-ref>scene-detection</schema-ref> </create-table> <graph> <title>ScenePlayer Behavior</title> <lane> <title>User Actions</title> <table-ref>user-actions</table-ref> <plot> <value-from>name</value-from> </plot> </lane> <lane> <title>Scene Detection</title> <table-ref>scene-detections</table-ref> <plot> <value-from>url</value-from> <color-from>result-color</color-from> </plot> </lane> </graph> <list> <title>User Actions</title> <table-ref>user-actions</table-ref> <column>time</column> <column>name</column> <column>message</column> </list> <list> <title>Scene Detection</title> <table-ref>scene-detections</table-ref> <column>start</column> <column>duration</column> <column>url</column> <column>scene-count</column> </list> </instrument> <template> <import-from-file>ScenePlayerBehavior.tracetemplate</import-from-file> </template> </package> ←116ߦ ScenePlayerBehavior.instrpkg
  7. CLIPS ࣜ͸()ͰғΉ ( ࣜ ) ม਺ ?hoge ԋࢉࢠ͸લஔ͖ (+ ?a

    ?b) (> ?t1 ?t2) factૢ࡞ ; ௥Ճ (assert hello) ; ࡟আ (retract ?hoge) ; มߋ (modify ?hoge (fuga 123))
  8. ϧʔϧΛఆٛ (defrule rule1 (car_problem (name ignition_key) (status on)) (car_problem (name

    engine) (status wont_start)) => (assert (car_problem (name starter) (status faulty))) ) (pattern 1) (pattern 2) … (pattern N) (action 1) … (action M) => શͯͷύλʔϯʹϚονͨ͠Β ΞΫγϣϯΛ࣮ߦ
  9. Getting Started with Instruments WWDC19, 411 Instruments֓ཁ, Time ProfilerͷσϞ, Signpostsͷ঺հ,

    XCTestͰͷར༻ྫ Measuring Performance Using Logging WWDC18, 405 Signposts APIৄࡉ Developing a Great Profiling Experience Telling your story with Custom Instruments WWDC19, 414 SignpostsʹΑΔσʔλऩूͷϕετϓϥΫςΟε, ΧελϜInstruments֓ཁ, ৘ใͷՄࢹԽ Creating Custom Instruments WWDC18, 410 InstrumentsͷΞʔΩςΫνϟ, ΧελϜInstrumentsͷ࡞੒ CLIPS User’s Guide www.clipsrules.net CLIPSݴޠͷجຊతͳ࢖͍ํͱγϯλοΫε Modeling in Custom Instruments WWDC19, 421 CLIPSʹΑΔModelerͷ࡞੒ ࢀߟࢿྉ ↓ ্͔ΒॱʹݟΔͱཧղ͠΍͍͢ͱࢥ͍·͢