Skip to content

Instantly share code, notes, and snippets.

@aschmied
Created December 30, 2014 21:46
Show Gist options
  • Save aschmied/8838f843a7f09f73ef46 to your computer and use it in GitHub Desktop.
Save aschmied/8838f843a7f09f73ef46 to your computer and use it in GitHub Desktop.
Time code execution in Swift
func timeIt(function: ()->()) -> Double {
var startTime = NSDate()
function()
return -startTime.timeIntervalSinceNow
}
let N = 800
var B = [Float](count: N, repeatedValue: 0)
elapsed = timeIt({
for i in 0..<N {
B[i] = Float(i)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment