How can I run my performance tests more than ten times?

前端 未结 4 1762
星月不相逢
星月不相逢 2021-02-12 05:59

By default Xcodes performance tests are run ten times and my result is the average of those ten tests. The problem is the averaged result varies considerably each time I run it

4条回答
  •  无人共我
    2021-02-12 06:09

    In the latest Xcode (11.0+) you don't need swizzling to change iterations count. Use the following function:

    func measure(options: XCTMeasureOptions, block: () -> Void)

    This will allow you to specify XCTMeasureOptions which has iterationCount property.

    Interesting note from docs:

    A performance test runs its block iterationCount+1 times, ignoring the first iteration and recording metrics for the remaining iterations. The test ignores the first iteration to reduce measurement variance associated with “warming up” caches and other first-run behavior.

提交回复
热议问题