Created
January 23, 2017 03:46
-
-
Save artemnovichkov/def8b4e51d7780eac2abbd4a4ff40272 to your computer and use it in GitHub Desktop.
Function for check algorithm efficiency
This file contains 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 benchmark(repeatCount: Int = 1, name: String? = nil, closure: () -> Void) { | |
let d = CACurrentMediaTime() | |
for _ in 0..<repeatCount { | |
closure() | |
} | |
let d1 = CACurrentMediaTime() - d | |
print("Benchmark of \(name ?? "closure") took \(d1) seconds") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment