Skip to content

Instantly share code, notes, and snippets.

@tsarikovskiy
Created June 22, 2018 09:38
Show Gist options
  • Select an option

  • Save tsarikovskiy/522e663b26b0ad77feb79db202632b1f to your computer and use it in GitHub Desktop.

Select an option

Save tsarikovskiy/522e663b26b0ad77feb79db202632b1f to your computer and use it in GitHub Desktop.
@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