Created
June 20, 2018 11:59
-
-
Save niwatako/e5c720ac3711c5406e0e350378f7fd6a to your computer and use it in GitHub Desktop.
『signpostsによるパフォーマンス計測』 #CodePiece #ca_swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CA.swift #6 WWDC18 報告会 - connpass | |
https://cyberagent.connpass.com/event/88328/ | |
## 『signpostsによるパフォーマンス計測』 | |
横山 祥平 | |
Measuring Performance Using Logging より | |
Xcode 10からsignpostsという新しいAPIが追加 | |
WWDC2016で紹介されたOSLogを拡張したAPI。Instrumentsで確認できる。 | |
``` | |
import os.signpost | |
let log = OSLog(subsystem:"bundle identifier", category:"Something") | |
os_signpost(.bigin,log: log, name:"doSomething()") | |
doSomething() | |
os_signpost(.end, log: log, name: "doSomething()") | |
``` | |
非同期はIDを振ることで実現できるよ | |
``` | |
import os.signpost | |
let log = OSLog(subsystem:"bundle identifier", category:"SomeOperation") | |
let id = OSSignpostID(log: OSLog.fetchResource) | |
os_signpost(.bigin,log: log, name:"doSomething()", signpostID: id) | |
// Async | |
doSomething() { | |
os_signpost(.end, log: log, name: "doSomething()", signpostID: id) | |
} | |
``` | |
C-APIライクにメタ情報を指定することができる | |
``` | |
os_signpost( | |
type: .bigin, | |
log: log, | |
name:"doSomething()", | |
signpostID: id, | |
"url: %s, indexPath.row: %d", url.absoluteString, indexPath | |
) | |
``` | |
shoheiyokoyama/DebuggingPerformance: Sample of measuring perfomance by using signposts | |
https://github.com/shoheiyokoyama/DebuggingPerformance | |
Demo: 画像を読み込んでTableに表示する。どのURLの画像をどれくらいの時間で読み込めたかがInstrumentsで確認できている。 | |
`pointsOfInterest` を仕掛けておくと、TimeProfilerからCPUUsageと、イベントの発生が確認できる。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment