-
-
Save sendoa/21f91f9f2e7858dc81ca to your computer and use it in GitHub Desktop.
Measures Time Taken for a closure to run
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
func measure(prefix: String = "Time Taken", closure:()->()) { | |
let a = CFAbsoluteTimeGetCurrent() | |
closure() | |
let b = CFAbsoluteTimeGetCurrent() | |
let m = ((b-a) * 1000.0) | |
print("\(prefix): \(m) ms") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment