Why do you get stuck?

The frequency of iPhone is 60 Hz, and the average time of each frame is 16.67ms. When the frame time occupied in APP is more than 16.67ms, the visual lag will be caused.

  • It is expressed in two ways:
    • HItch Time: Indicates the time for which the frame delay is displayed (ms).
    • Hitch Ratio: Time of delay per second, ms/s.
  • Hitch Ratio rating:
    • Good: 5 ms/s or less
    • Warning: ≥ 5ms/s && < 10ms/s
    • Critical: 10 ms/s or higher

How to detect caton? – XCTOSSignpostMetric

  • Use alternate configurations of XCTOSSignpostMetric: prevent these configurations from affecting test results
    • Scheme -> Test -> Build Configuration to Release.
    • Xctestplan -> Configurations -> Automatic Screenshots to Off.
    • Xctestplan -> Configurations -> Code Coverage to Off.
    • Xctestplan -> Configurations -> Runtime Sanitization/Runtime API Checking/Memory Management is implemented for the client.
  • XCTOSSignpostMetric tests five times by default.
  • Test code:
func testScrollingAnimationPerformance() throws { // step1 let app = XCUIApplication() app.launch() app.staticTexts["Meal Planner"].tap() let foodCollection = app.collectionViews.firstMatch // step2 let meausreOptions = XCTMeasureOptions() meausreOptions.invocationOptions = [.manuallyStop] // step3 measure(metrics: [XCTOSSignpostMetric scrollDraggingMetric], the options: meausreOptions) {/ / upward sliding foodCollection. SwipeUp (velocity: .fast) // Stop testing stopMeasuring() // Slide foodCollection.swipedown (velocity:.fast)}}Copy the code
  • Code instructions

    • Step1, enter the relevant test page.
    • Step2: configure XCTMeasureOptions to manually stop each test.
    • Step3: test relevant indicators of XCTOSSignpostMetric.
  • The reason for adding manual stop, stop test, and slide down code to reset the environment is to ensure that the environment is consistent each time you test so that the test results are relatively correct.

  • XCTOSSignpostMetric A testable metric

    • NavigationTransitionMetric: testing navigation between two view the animation.
    • CustomNavigationTransitionMetric: testing custom navigation between two view the animation.
    • Scrollactivity: Animation to test deceleration.
    • ScrollDraggingMetric: Tests animation while sliding.