Created
July 6, 2016 17:27
-
-
Save jairobjunior/d694080c2a59981838a1b6b0511df46a to your computer and use it in GitHub Desktop.
Simple benchmarking func in Swift to display block execution 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
public func benchmarking(operationName: String, operation: ()->()) { | |
let startTime = CFAbsoluteTimeGetCurrent() | |
operation() | |
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime | |
print("Time elapsed for \(operationName): \(timeElapsed) s") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment