Skip to main content

Posts

Showing posts from May, 2021

How to check the time taken by a method to execute the code in Swift?

CFAbsoluteTimeGetCurrent() returns absolute time measured in seconds. let startTime = CFAbsoluteTimeGetCurrent() doSomeWork() let difference = CFAbsoluteTimeGetCurrent() - startTime print(“Your method took \(difference) seconds") func doSomeWork() { //Write your code here } Official documentation:  https://developer.apple.com/documentation/corefoundation/1543542-cfabsolutetimegetcurrent