XCTMetrics 중 XCTOSSignpostMetric 사용
이를 위해서는 앱에 os_signpost 신호를 보내야 함 → 시스템 건 자동으로 되어 있고, 커스텀하면 직접 이를 보내야 함
// 비 애니매이션 용
os_signpost(.begin, log: logHandle, name: "performInterval")
os_signpost(.end, log: logHandle, name: "performInterval")
// XCode 12 용으로 나온 애니매이션 용
os_signpost(.animationBegin, log: logHandle, name: "performAnimationInterval")
os_signpost(.end, log: logHandle, name: "performAnimationInterval")
테스트 예제
func testScrollingAnimationPerformance() throws {
app.launch()
app.staticTexts["Meal Planner"].tap()
let foodCollection = app.collectionViews.firstMatch
let measureOptions = XCTMeasureOptions()
measureOptions.invocationOptions = [.manuallyStop]
measure(metrics: [XCTOSSignpostMetric.scrollDecelerationMetric],
options: measureOptions) {
foodCollection.swipeUp(velocity: .fast)
stopMeasuring() // 위 옵션을 통해서 수동으로 멈출 수 있게 됨
foodCollection.swipeDown(velocity: .fast) // 스크롤 상태 원래대로 되돌림
}
}