Skip to content

Instantly share code, notes, and snippets.

@hannesstruss
Created October 27, 2016 09:20
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 hannesstruss/755e6525c9791b0d53b39a004d598fe5 to your computer and use it in GitHub Desktop.
Save hannesstruss/755e6525c9791b0d53b39a004d598fe5 to your computer and use it in GitHub Desktop.
Swift measure time
import Foundation
func measure(op: () -> ()) -> Double {
let startTime = CFAbsoluteTimeGetCurrent()
op()
let elapsed = CFAbsoluteTimeGetCurrent() - startTime
return Double(elapsed)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment