Skip to main content


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: