Simple way to measure duration of function in Swift
Measure: 1.0072 (MyPlayground sleep() line 35)`
Drag & drop Measure.swift
into project
voidFunction()
->
measure {
voidFunction()
}
let users = Users.loadFromDatabase()
->
let users = measure { Users.loadFromDatabase() }
let user = try JSONDecoder().decode(User.self, from: json)
->
let user = try measure { try JSONDecoder().decode(User.self, from: json) }
voidFunction()
->
measure("Just function") {
voidFunction()
}