https://github.com/fluidgroup/swift-stopwatch
A simple and lightweight stopwatch library for Swift.
https://github.com/fluidgroup/swift-stopwatch
Last synced: about 1 year ago
JSON representation
A simple and lightweight stopwatch library for Swift.
- Host: GitHub
- URL: https://github.com/fluidgroup/swift-stopwatch
- Owner: FluidGroup
- License: apache-2.0
- Created: 2025-04-08T13:59:56.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-08T14:04:22.000Z (about 1 year ago)
- Last Synced: 2025-04-08T15:22:06.190Z (about 1 year ago)
- Language: Swift
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stopwatch
A simple and lightweight stopwatch library for Swift.
## Features
- High-precision timing using `mach_absolute_time()`
- Non-copyable struct design
- Simple and intuitive API
- Microsecond and millisecond precision
## Installation
### Swift Package Manager
Add the following to your `Package.swift`:
```swift
dependencies: [
.package(url: "https://github.com/FluidGroup/swift-stopwatch.git", from: "1.0.0")
]
```
## Usage
```swift
import Stopwatch
// Create a stopwatch with a name
let stopwatch = Stopwatch(name: "My Operation")
// Do some work...
// End the stopwatch and print the elapsed time
stopwatch.end()
```
The output will show the elapsed time in both microseconds (μs) and milliseconds (ms).
## Requirements
- Swift 6.0 or later