Skip to content

Instantly share code, notes, and snippets.

@sendoa
Forked from MugunthKumar/measure.swift
Created February 22, 2016 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sendoa/21f91f9f2e7858dc81ca to your computer and use it in GitHub Desktop.
Save sendoa/21f91f9f2e7858dc81ca to your computer and use it in GitHub Desktop.
Measures Time Taken for a closure to run
func measure(prefix: String = "Time Taken", closure:()->()) {
let a = CFAbsoluteTimeGetCurrent()
closure()
let b = CFAbsoluteTimeGetCurrent()
let m = ((b-a) * 1000.0)
print("\(prefix): \(m) ms")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment