Last active
January 20, 2021 12:07
-
-
Save V8tr/e030176b09db21cf9578ebbec8e1f0e6 to your computer and use it in GitHub Desktop.
Benchmark arbitrary block of code in Swift. See blog post for more details: http://www.vadimbulavin.com/benchmarking-locking-apis/
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 benchmark(block: () -> Void) -> TimeInterval { | |
let startTime = CFAbsoluteTimeGetCurrent() | |
block() | |
let endTime = CFAbsoluteTimeGetCurrent() | |
let totalTime = endTime - startTime | |
return totalTime | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment