Timekeeper

Build
Documentation

Timekeeper is an easy-to-use time measurement library written in Swift, with support for iOS, tvOS, watchOS and macOS.

Installation

Timekeeper is available via the Swift Package Manager which is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system and automates the process of downloading, compiling, and linking dependencies.

Once you have your Swift package set up, adding Timekeeper as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(
        url: "https://github.com/aplr/Timekeeper.git",
        .upToNextMajor(from: "0.0.1")
    )
]

Usage

import Timekeeper

// Start a new timing
Timekeeper.shared.start("measurement")

// Print the elapsed time since start
Timekeeper.shared.lap(print: "measurement")

// Print the elapsed time since the last lap
Timekeeper.shared.lap(print: "measurement")

// Print the elapsed time since the last lap and start and clears the timing
Timekeeper.shared.stop(print: "measurement")

// Start a new timing
Timekeeper.shared.start("measurement")

// Add a new lap and return the timing
let measurement = Timekeeper.shared.lap("measurement")

// Stop the timer and return the timing
let measurement = Timekeeper.shared.stop("measurement")

Documentation

Documentation is available here and provides a comprehensive documentation of the library’s public interface.

License

Timekeeper is licensed under the MIT License.

GitHub

View Github