Slide 1

Slide 1 text

ߦ໦ ઍय़ʢͳΊ͖ ͪ͸Δʣ Twitter, Qiita, GitHub @Ridwy גࣜձࣾαΠόʔΤʔδΣϯτ ΧελϜInstrumentsͰ ΞϓϦΛϐΧϐΧʹʂ iOSDC Japan 2019 Sep. 7

Slide 2

Slide 2 text

Instruments

Slide 3

Slide 3 text

Agenda • Instrumentsͷجຊ • OSSignposts • ΧελϜInstrumentsͷ࡞੒ • ׆༻ࣄྫ • CLIPSʹΑΔModelerͷࣗ࡞

Slide 4

Slide 4 text

ύϑΥʔϚϯεͳͲͷ඼࣭վળʹ໾ཱͭ ࣮ߦ࣌ʹ͞·͟·ͳ৘ใΛऩू͠ ෼ੳɾՄࢹԽͯ͘͠ΕΔπʔϧ

Slide 5

Slide 5 text

Xcodeʹ૊Έࠐ·Ε͍ͯΔ ܭଌର৅ʹΞϓϦ͕ηοτ͞Εͨঢ়ଶͰىಈ Product > Profile

Slide 6

Slide 6 text

୯ಠͰ΋ىಈͰ͖Δ

Slide 7

Slide 7 text

جຊͷ࢖͍ํ

Slide 8

Slide 8 text

ςϯϓϨʔτΛબ୒ͯ͠Choose !

Slide 9

Slide 9 text

ϝΠϯը໘

Slide 10

Slide 10 text

Record !

Slide 11

Slide 11 text

݁ՌΛݟͯίʔυΛվળ

Slide 12

Slide 12 text

Instruments ͱ͍͏୯ޠ͸ 2ͭͷҙຯͰ࢖ΘΕ͍ͯ·͢ ͜͜Ͱͪΐͬͱ஫ҙ

Slide 13

Slide 13 text

Instruments.app

Slide 14

Slide 14 text

֤छͷ෼ੳΛߦ͏πʔϧ Drag & Drop Ͱ௥Ճʂ Instruments ϥΠϒϥϦ

Slide 15

Slide 15 text

ը໘ߏ੒

Slide 16

Slide 16 text

ը໘ߏ੒ Track Area Detail Area Extended Detail Area Track (=࣌ܥྻͷάϥϑ) ͕ฒͿ

Slide 17

Slide 17 text

Instrument Track graph lane lane άϥϑ͕ෳ਺͋Δͱ͖͸ ͜͜Ͱ੾Γସ͑

Slide 18

Slide 18 text

Leaks Standard ςϯϓϨʔτ ❌ϝϞϦ࢖༻ྔ͕ӈݞ্͕Γ ❌ϦʔΫʂ

Slide 19

Slide 19 text

Time Profiler Standard ςϯϓϨʔτ CPU࢖༻཰ΛՄࢹԽ ࣌ؒͷ͔͔Δؔ਺ͷಛఆʹ Application status΋දࣔ͞ΕΔ Backgroundதͷڍಈ΋֬ೝ͠΍͍͢

Slide 20

Slide 20 text

ίΞΛޮ཰Α͘ ࢖͍͑ͯΔ͔ʁ ؔ਺ͷ࣮ߦʹ͔͔ͬͨ࣌ؒ

Slide 21

Slide 21 text

AVPlayerItemOutputPullDelegate outputSequenceWasFlushed(_:) ಈըͷը͕Ͱ͖ͨΒݺ͹ΕΔ = ܁Γฦ࣮͠ߦ͞ΕΔՕॴ [AVVideoAsset minFrameDuration] 1ϑϨʔϜ͕Կඵ͔ 1ճ͋ͨΓ͸େͨ͜͠ͱͳ͍͕ ਖੵͰҙ֎ͱ͕͔͔͍࣌ؒͬͯΔ → ϧʔϓͷ֎ʹग़ͦ͏ʂ

Slide 22

Slide 22 text

Energy Log Standard ςϯϓϨʔτ ֤ϋʔυ΢ΣΞͷঢ়ଶ ΧλϩάతͳςϯϓϨʔτʁ

Slide 23

Slide 23 text

ΧελϜςϯϓϨʔτ ݱࡏͷ૊Έ߹ΘͤΛΧελϜςϯϓϨʔτͱͯ͠ॻ͖ग़ͤΔ Hoge.tracetemplate File > Save As Template… อଘ৔ॴ ~/Library/Application Support/Instruments/Templates ͜͜ʹஔ͘ͱςϯϓϨʔτબ୒ը໘ʹݱΕΔ μϒϧΫϦοΫͰ΋ىಈ

Slide 24

Slide 24 text

ϐΧϐΧʹ͠Α͏ʂ جຊฤ ͜͜·Ͱ

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

ԿΛ͚ͨ࣌ͩͬ͠…ʁʁ ͲΜͳૢ࡞Λͯ͠ɺը໘͸Ͳ͏͔ͩͬͨ? ޙ͔ΒݟΔͱ…

Slide 27

Slide 27 text

Command Line࣮ߦ ޙ͔Β݁ՌΛΈΔέʔε ̍ $instruments -t "Allocations" -l 10000 -D SaveFileName.trace PathToYourApp ςϯϓϨʔτ ه࿥࣌ؒ(ϛϦඵ) อଘઌ ଌఆର৅

Slide 28

Slide 28 text

Deferred Recording Mode ޙ͔Β݁ՌΛΈΔέʔε ̎ Instrumentsࣗମͷಈ࡞ʹΑΔӨڹΛ ࠷௿ݶʹ཈͑ΔͨΊ෼ੳΛ஗Ԇ࣮ߦͰ͖Δ or File > Recording Options…

Slide 29

Slide 29 text

OSSignposts ʮίʔυ͕ԿΛ͍ͯ͠Δॴ͔ʯΛ Instrumentsʹ఻͑Α͏

Slide 30

Slide 30 text

Point os_signpost(.event, log: logHandle, name: "Seek","to: %f", t) os_signpost()ΛίʔυʹຒΊࠐΉ Կ͕ൃੜͨ͠ͷ͔ʁΛૹΔ

Slide 31

Slide 31 text

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()ΛίʔυʹຒΊࠐΉ

Slide 32

Slide 32 text

ϨίʔσΟϯάதͰͳ͍ͱ͖ͷ ίʔυͷ࣮ߦʹΠϯύΫτΛ༩͑ͳ͍Α͏ʹ஫ҙ 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

Slide 33

Slide 33 text

ϝοηʔδ΋දࣔ͞ΕΔ Instrument ͷ os_signpost ΍ Points of Interest ʹදࣔ͞ΕΔ

Slide 34

Slide 34 text

• άϥϑͷ৭, Ϧετͷ಺༰, etc. • Signposts͸ڞ௨ͷϦιʔεͳͷͰɺࣗ෼͕௥Ճͨ͠΋ͷ
 Ҏ֎΋ग़ͯ͘Δ ͖ͬ͞௥Ճͨ͠ͷɺͲΕ? ͍Ζ͍Ζɺݟ΍ͨ͘͘͢͠ͳͬͯ͘Δ શ෦੨͍…

Slide 35

Slide 35 text

ΧελϜInstruments

Slide 36

Slide 36 text

Instruments Architecture Data Stream Table Modeler Table Standard UI Signposts, ktraceͳͲͷσʔλͷιʔε Data Stream Table σʔλͷೖΕ෺ɼܕ͸εΩʔϚͰఆٛ Modeler ೖྗσʔλΛධՁͯ͠ग़ྗσʔλΛੜ੒ Standard UI InstrumentsΞϓϦͷUI

Slide 37

Slide 37 text

Instruments Architecture Dynamic Track-wide Binding 1. InstrumentsʹඞཁͳςʔϒϧΛ༻ҙ 2.ͦͷςʔϒϧͷεΩʔϚͷσʔλΛੜ੒Ͱ͖Δ
 Modeler / Data StreamΛ୳ͯ͠όΠϯσΟϯά ޮ཰ԽͷͨΊɺಉ͡಺༰ͷςʔϒϧ͸ڞ༗͢Δ

Slide 38

Slide 38 text

ΧελϜInstrumentsΛ࡞Δ InstrumentsͱඞཁͳModeler, εΩʔϚͳͲΛؚΉ
 ύοέʔδΛ࡞Δ =

Slide 39

Slide 39 text

࡞੒खॱ Xcode Ͱ File > New > Project… macOS಺ͷ Instruments Package Λબ୒

Slide 40

Slide 40 text

instrpkgϑΝΠϧʹXMLͰ
 εΩʔϚ΍Modeler, InstrumentsͳͲΛهड़ Snippet͕ॆ࣮ʂ

Slide 41

Slide 41 text

• Run → σόοάϞʔυͰInstruments͕ىಈ • Archive → ഑෍༻ύοέʔδΛੜ੒ ActionLogs.instrdst ར༻࣌͸͜ΕΛ μϒϧΫϦοΫͯ͠Πϯετʔϧ

Slide 42

Slide 42 text

ΠϯετʔϧࡁΈͷύοέʔδ͸ ؀ڥઃఆͷPackagesλϒͰ֬ೝͰ͖Δ

Slide 43

Slide 43 text

XMLཁૉͷϦϑΝϨϯε Instruments Developer Help Package Definition Reference Engineering TypeʢΧϥϜͷσʔλछผʣͷϦετ΋ͪ͜Βʂ

Slide 44

Slide 44 text

εΩʔϚ εΩʔϚ Instruments Package ͷߏ੒ྫ

Slide 45

Slide 45 text

εΩʔϚΛهड़͢ΔͨΊͷXMLཁૉ XML Element Automatic Modeler Memo ○ ○ Xcode 11~ ○ Automatic Modeler = ModelerΛࣗಈੜ੒ͯ͘͠ΕΔػೳ os_signpost΍os_log͔Βఆٛ͞ΕͨεΩʔϚʹม׵ʂ

Slide 46

Slide 46 text

εΩʔϚ Ұཡ Instrument > Instrument Inspector Schemasλϒ 100+ Built-in Schemas !

Slide 47

Slide 47 text

طଘεΩʔϚͷར༻ํ๏ os-signpost ඞཁͳΒBuild SettingsͰύοέʔδΛϦϯΫ

Slide 48

Slide 48 text

jp.co.chiharu-nameki.ScenePlayerBehavior ScenePlayerBehavior Chiharu Nameki os-signpost scene-detection Scene Detection "jp.co.chiharu-nameki.ScenePlayer" "Behavior" "Scene Detection" "url: " ?url "count: " ?count url Video URL string ?url scene-count Scene Count uint32 ?count result-color Color event-concept (if (= ?count 0) then "Red" else "Green") jp.co.chiharu-nameki.ScenePlayerBehavior.ScenePlayerBehavior ScenePlayer Behavior Behavior Visualize what's happen in ScenePlayer app Points of Interest user-actions os-signpost subsystem jp.co.chiharu-nameki.ScenePlayer category UserAction scene-detections scene-detection ScenePlayer Behavior User Actions user-actions name Scene Detection scene-detections url result-color User Actions user-actions time name message Scene Detection scene-detections start duration url scene-count ScenePlayerBehavior.tracetemplate ←116ߦ ScenePlayerBehavior.instrpkg

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

API௨৴ͷՄࢹԽ ϓϩμΫτͰͷ׆༻ࣄྫ ̍ ޮ཰ͷѱ͍ϦΫΤετͷ࢓ํΛ͍ͯ͠ͳ͍͔ʁ

Slide 51

Slide 51 text

Ϣʔβʔͷߦಈϩάͷ࣮૷֬ೝ ϓϩμΫτͰͷ׆༻ࣄྫ ̎ ՄࢹԽػೳʹண໨ λΠϛϯά΍಺༰͕ਖ਼͍͔͠νΣοΫ

Slide 52

Slide 52 text

΋ͬͱݡ͘͠Α͏ʂ ΧελϜModeler

Slide 53

Slide 53 text

A Tool for Building Expert Systems www.clipsrules.net

Slide 54

Slide 54 text

Expert System ઐ໳Ոͷ൑அೳྗΛΤϛϡϨʔτ͢Δ΋ͷ ࣗಈి࿩Ԡ౴ɺੲͳ͕ΒͷAIʢ͍ΘΏΔਓ޻ແ೴ʣͳͲʹԠ༻ ൃੜͨ͠ࣄ࣮ʢfactʣΛϧʔϧʹैͬͯॲཧ Working memory fact f-2 Rule B Rule A fact f-1 fact f-3

Slide 55

Slide 55 text

CLIPS ࣜ͸()ͰғΉ ( ࣜ ) ม਺ ?hoge ԋࢉࢠ͸લஔ͖ (+ ?a ?b) (> ?t1 ?t2) factૢ࡞ ; ௥Ճ (assert hello) ; ࡟আ (retract ?hoge) ; มߋ (modify ?hoge (fuga 123))

Slide 56

Slide 56 text

ϧʔϧΛఆٛ (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) => શͯͷύλʔϯʹϚονͨ͠Β ΞΫγϣϯΛ࣮ߦ

Slide 57

Slide 57 text

۩ମྫ ߦಈϩάͷ࣮૷ϛεΛݕ஌ͤ͞Δ • λοϓͷϩάʹ͸Page IDʢͲͷը໘Ͱߦͳ͔ͬͨʣͷ৘ใؚ͕·ΕΔ • Page ID͸දࣔதͷը໘ͱಉ͡Ͱ͋Δ΂͖

Slide 58

Slide 58 text

ཁૉʹೖग़ྗͷεΩʔϚͱCLIPSͷϑΝΠϧ΁ͷύεΛهड़

Slide 59

Slide 59 text

page-id-validator.clp શจ ϧʔϧΛهड़

Slide 60

Slide 60 text

ݕग़͞Εͨʂ

Slide 61

Slide 61 text

Recap • Instrumentsͷجຊ • OSSignposts • ΧελϜInstrumentsͷ࡞੒ • ׆༻ࣄྫ • CLIPSʹΑΔModelerͷࣗ࡞

Slide 62

Slide 62 text

Sample Code https://github.com/Ridwy/iosdc19-custom-instruments ActionLogs ScenePlayer.app w/ Instrument Custom Modeler Sample

Slide 63

Slide 63 text

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ͷ࡞੒ ࢀߟࢿྉ ↓ ্͔ΒॱʹݟΔͱཧղ͠΍͍͢ͱࢥ͍·͢

Slide 64

Slide 64 text

Instruments Help جຊͷ࢖͍ํ Instruments Developer Help ύοέʔδͷXMLཁૉ, Engineering TypeҰཡ ࢀߟࢿྉ

Slide 65

Slide 65 text

͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠