Go to file
YOCKOW 8e4de4e0fb
Merge pull request #7 from YOCKOW/development
Confirm compatibility with Swift 5.4.
2021-05-09 21:49:17 +09:00
.github/workflows Remove LinuxMain.swift and XCTestManifests.swift 2021-05-09 18:21:51 +09:00
Sources/TimeSpecification Add type aliases of `TimeSpecification`. 2020-05-28 14:40:05 +09:00
Tests/TimeSpecificationTests Remove LinuxMain.swift and XCTestManifests.swift 2021-05-09 18:21:51 +09:00
.gitignore Use GitHub Actions. 2020-05-22 14:18:46 +09:00
LICENSE.txt Introduced Swift Package Manager and XCTest instead of swift-tap 2017-09-02 10:36:00 +09:00
Package.swift Migrate to Swift5 & Change APIs. 2019-04-14 11:08:03 +09:00
README.md Implement `static func measure(repeatCount:_:)` 2020-05-24 13:09:57 +09:00

README.md

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.