【发布时间】:2020-04-26 20:37:18
【问题描述】:
我需要测试性能标准的以下代码行。但不幸的是,Apple Document 无助于对此有清晰的了解。
func addStrings() {
let maxCount = 100000
var array:Array<String> = Array()
for _ in 0..<maxCount {
array.append("Test")
}
}
性能测试用例代码如下。
func testPerformanceExample() throws {
// This is an example of a performance test case.
let strings = StringsCreator()
self.measure {
// Put the code you want to measure the time of here.
strings.addStrings()
}
}
从结果看来,第一个值是平均值的 21.3%(0.0611 秒)。但是其余的属性是什么意思呢?以及如何将它们(基线和最大 STD Dev)设置为可接受的标准?
它如何计算结果是 88% 好,什么是 +- 8%?
【问题讨论】:
标签: swift xcode performance-testing standard-deviation