TimeSpecification

3.3.0

Get `timespec` in Swift.
YOCKOW/SwiftTimeSpecification

What's New

3.3.0

2022-09-27T08:48:17Z

What's Changed

Full Changelog: 3.2.0...3.3.0

What is SwiftTimeSpecification?

SwiftTimeSpecification is an implementation of struct timespec (struct mach_timespec on OS X) in Swift.
Its prototype is YOCKOW's Gist.

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 (including compatibility mode for 4, 4.2)
  • macOS or Linux

License

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

Description

  • Swift Tools 5.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Feb 03 2023 18:00:41 GMT-0500 (GMT-05:00)