Skip to content

Simple way to measure duration of function in Swift

Notifications You must be signed in to change notification settings

vkosmirak/Measure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

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()
}

About

Simple way to measure duration of function in Swift

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages