Skip to content

Instantly share code, notes, and snippets.

@danie7k
Created October 18, 2019 09:27
Show Gist options
  • Save danie7k/7a39f8b5e9bc9882b8c481b9af72f52c to your computer and use it in GitHub Desktop.
Save danie7k/7a39f8b5e9bc9882b8c481b9af72f52c to your computer and use it in GitHub Desktop.
Quick Performance Timing
@discardableResult
func measure<A>(name: String = "", _ block: () -> A) -> A {
let startTime = CACurrentMediaTime()
let result = block()
let timeElapsed = CACurrentMediaTime() - startTime
print("Time: \(name) - \(timeElapsed)")
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment