| 测试已测试 | ✗ |
| Lang语言 | SwiftSwift |
| 许可证 | MIT |
| Released上次发布 | 2017年5月 |
| SwiftSwift版本 | 3.0 |
| SPM支持SPM | ✗ |
由WorldDownTown维护。
Benchmark⏲模块提供了测量和报告Swift代码执行时间的方法。
import Benchmark
Benchmark.measure() {
print(self) // don't have to set weak.
for _ in 0...10000000 { }
}
// Benchmark: 0.1690970063 sec.
// Benchamrk can be set name.
Benchmark.measure("Measure1") {
for _ in 0...10000000 { }
}
// Measure1: 0.1690970063 sec.import Benchmark
func heavyMethod() {
let outer = Benchmark(key: "outer")
let inner = Benchmark(key: "inner")
// some light processes
for _ in 0...10 { }
inner.finish() // inner: 0.0002210140 sec.
// some heavy processes
for _ in 0...10000000 { }
outer.finish() // outer: 0.1663100123 sec.
}import Benchmark
class Foo {
func execute() {
Benchmark.start()
}
}
class Bar {
func execute() {
Benchmark.finish()
}
}
Foo().execute()
Bar().execute() // Benchmark: 0.0001509786 sec.import Benchmark
// same as Benchmark.measure {}
⏲{
for _ in 0...10000000 { }
}
// Benchmark: 0.1653281017 sec.欢迎贡献!如果您希望对Benchmark进行改进或添加功能,请随时发送pull request!
WorldDownTown @ gmail.com
Benchmark在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。