Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 768 Bytes

README.md

File metadata and controls

59 lines (45 loc) · 768 Bytes

Measure

Simple way to measure duration of function in Swift

Log:

Measure: 1.0072 (MyPlayground sleep() line 35)`

Installation:

Drag & drop Measure.swift into project

How to use

1. Function

voidFunction()

->

measure {
    voidFunction()
}

2. Function with return value

let users = Users.loadFromDatabase()

->

let users = measure { Users.loadFromDatabase() }

3. Function with throwing error

let user = try JSONDecoder().decode(User.self, from: json)

->

let user = try measure { try JSONDecoder().decode(User.self, from: json) }

4. Named measuring

voidFunction()

->

measure("Just function") {
    voidFunction()
}