Created
October 18, 2019 09:27
-
-
Save danie7k/7a39f8b5e9bc9882b8c481b9af72f52c to your computer and use it in GitHub Desktop.
Quick Performance Timing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@discardableResult | |
func measure<A>(name: String = "", _ block: () -> A) -> A { | |
let startTime = CACurrentMediaTime() | |
let result = block() | |
let timeElapsed = CACurrentMediaTime() - startTime | |
print("Time: \(name) - \(timeElapsed)") | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment