Go to file
YOCKOW d0007005ad minor fix 2017-09-04 16:57:50 +09:00
Sources `timeSpecification` of `Clock` is now a computed property. 2017-09-04 16:48:33 +09:00
Tests Introduced Swift Package Manager and XCTest instead of swift-tap 2017-09-02 10:36:00 +09:00
.gitignore Introduced Swift Package Manager and XCTest instead of swift-tap 2017-09-02 10:36:00 +09:00
.travis.yml Add ".travis.yml" 2017-05-09 15:45:52 +09:00
LICENSE.txt Introduced Swift Package Manager and XCTest instead of swift-tap 2017-09-02 10:36:00 +09:00
Package.swift Introduced Swift Package Manager and XCTest instead of swift-tap 2017-09-02 10:36:00 +09:00
README.md `timeSpecification` of `Clock` is now a computed property. 2017-09-04 16:48:33 +09:00
build-install.rb minor fix 2017-09-04 16:57:50 +09:00

README.md

What is SwiftTimeSpecification?

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

Branch Build Status
master Build Status
development Build Status

Class, Structure, Enumeration

public struct TimeSpecification {
  public var seconds:Int64 = 0
  public var nanoseconds:Int32 = 0
  /* ... */
}
public enum Clock {
  case Calendar
  case System
  
  public var timeSpecification: TimeSpecification? {
    /* ... */
  }
}

How to use

Build and install:
./build-install.rb --install-prefix=/path/to/your/system --install
Then, you can use it in your project:
swiftc ./your/project/main.swift -I/path/to/your/system/include -L/path/to/your/system/lib -lSwiftTimeSpecification

Sample Code

import TimeSpecification

func time(_ body:() -> Void) {
  guard let start = Clock.System.timeSpecification else { return }
  body()
  guard let end = Clock.System.timeSpecification else { return }
  let duration = end - start
  print("\(duration)")
}