Contents

yockow/swifttimespecification

SwiftTimeSpecification is an implementation of `struct timespec` (`struct mach_timespec` on OS X) in Swift.

Sample Code

Measure

import TimeSpecification

let duration = TimeSpecification.measure(repeatCount: 100) { doIt() }
print("It took \(duration) seconds.") // -> Processing time to execute `doIt` 100 times. 

With Date

import TimeSpecification

let now = TimeSpecification(clock: .calendar)
let dateNow = Date(timeIntervalSince1970: now) // -> Almost same with Date(timeIntervalSince1970: Double(time(nil)))

Requirements

  • Swift 5, 6 (including language mode for 4, 4.2)
  • macOS or Linux

License

MIT License. See "LICENSE.txt" for more information.

Package Metadata

Repository: yockow/swifttimespecification

Default branch: main

README: README.md