Go to file
YOCKOW aa82e622df Merge branch 'development' (SwiftPM & XCTest available) 2017-09-02 10:40:34 +09:00
Sources Introduced Swift Package Manager and XCTest instead of swift-tap 2017-09-02 10:36:00 +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 Introduced Swift Package Manager and XCTest instead of swift-tap 2017-09-02 10:36:00 +09:00
build-install.rb Introduced Swift Package Manager and XCTest instead of swift-tap 2017-09-02 10:36:00 +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: Comparable,
                                 ExpressibleByIntegerLiteral,
                                 ExpressibleByFloatLiteral {
  public var seconds:Int64 = 0
  public var nanoseconds:Int32 = 0
  /* ... */
}
public enum Clock {
  case Calendar
  case System
  
  public func 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
let start = Clock.System.timeSpecification()
// your code
let end = Clock.System.timeSpecification()

if start != nil && end != nil {
  let duration = end! - start!
  // For example, duration == TimeSpecification(seconds:0, nanoseconds:100)
  print("\(duration)") 
}