SwiftTimeSpecification 是 Swift 中对 struct timespec
(在 OS X 上是 struct mach_timespec
) 的实现。
其原型参见 YOCKOW 的 Gist。
import TimeSpecification
let duration = TimeSpecification.measure(repeatCount: 100) { doIt() }
print("It took \(duration) seconds.") // -> Processing time to execute `doIt` 100 times.
import TimeSpecification
let now = TimeSpecification(clock: .calendar)
let dateNow = Date(timeIntervalSince1970: now) // -> Almost same with Date(timeIntervalSince1970: Double(time(nil)))
MIT 许可证。
有关更多信息,请参阅 "LICENSE.txt"。