Created
January 14, 2020 03:15
-
-
Save vnsam/d7219fd70abd3ffb391cdee348b4235a to your computer and use it in GitHub Desktop.
Measure Swift Code Running Time
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 duration(_ block: () -> Void) { | |
let startTime = CFAbsoluteTimeGetCurrent() | |
block() | |
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime | |
print(timeElapsed) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment