基准测试

Swift: 4.0 OS: Linux | macOS | iOS | watchOS | tvOS License: MIT

Benchmark 库提供了一些函数,帮助你 выяснить 执行某些代码需要多长时间(包括实际运行时间和 CPU 时间)。

函数

timethis

	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)