Created
December 30, 2014 21:46
-
-
Save aschmied/8838f843a7f09f73ef46 to your computer and use it in GitHub Desktop.
Time code execution in Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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