It's simple.
At the start of the function add:
let start = mach_absolute_time()
and at the end of the function add:
let endNano = mach_absolute_time() - start
let endSec = TimeInterval(endNano) / TimeInterval(NSEC_PER_SEC)
print("\(#function) - \(endSec)")
For example:
override func viewDidLoad() {
let start = mach_absolute_time()
super.viewDidLoad()
…
// do other stuff
…
let endNano = mach_absolute_time() - start
let endSec = TimeInterval(endNano) / TimeInterval(NSEC_PER_SEC)
print("\(#function) - \(endSec)")
}
Easy.