Benchmark 库提供了一些函数,帮助你 выяснить 执行某些代码需要多长时间(包括实际运行时间和 CPU 时间)。
func timethis(count: Int, title: String? = nil, _ body: () throws -> Void) rethrows
多次运行一段代码。结果将被打印到 STDOUT。
timethis(count: 3) {
// do something
}
// Output:
// 0.444793617 wallclock secs (0.308 usr + 0.004 sys = 0.312 CPU)