Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yockow/swifttimespecification
Get `timespec` in Swift.
https://github.com/yockow/swifttimespecification
nanoseconds swift
Last synced: 24 days ago
JSON representation
Get `timespec` in Swift.
- Host: GitHub
- URL: https://github.com/yockow/swifttimespecification
- Owner: YOCKOW
- License: mit
- Created: 2016-05-27T04:04:05.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-10-04T08:34:53.000Z (about 1 month ago)
- Last Synced: 2024-10-09T16:29:12.154Z (about 1 month ago)
- Topics: nanoseconds, swift
- Language: Swift
- Size: 59.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# What is SwiftTimeSpecification?
SwiftTimeSpecification is an implementation of `struct timespec` (`struct mach_timespec` on OS X) in Swift.
Its prototype is [YOCKOW's Gist](https://gist.github.com/YOCKOW/12d9607cb30f40b79fb2).## Sample Code
### Measure
```Swift
import TimeSpecificationlet duration = TimeSpecification.measure(repeatCount: 100) { doIt() }
print("It took \(duration) seconds.") // -> Processing time to execute `doIt` 100 times.```
### With `Date`
```Swift
import TimeSpecificationlet 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.