如何运行性能测试十次以上? [英] How can I run my performance tests more than ten times?

查看:38
本文介绍了如何运行性能测试十次以上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,Xcodes性能测试运行十次,而我的结果是这十次测试的平均值.问题是每次运行时平均结果差异很大,因此我必须至少运行五次测试才能得出收敛的结果.这既繁琐又费时;有没有办法配置XCode或单元测试本身运行十次以上?

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 so I have to run the test at least five times to get a converged result. This is both tedious and time consuming; is there a way to configure either XCode or the unit test itself to run more than ten times?

推荐答案

在最新的Xcode(11.0+)中,您无需费力即可更改迭代次数.使用以下功能:

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

func measure(选项:XCTMeasureOptions,块:()->无效)

这将允许您指定 XCTMeasureOptions 具有 iterationCount 属性.

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

文档中的有趣注释:

性能测试会运行其块 iterationCount + 1 ,而忽略第一次迭代并记录其余迭代的指标.该测试忽略了第一次迭代以减少与预热"缓存和其他首次运行行为相关的测量差异.

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.

这篇关于如何运行性能测试十次以上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆