Skip to content

Instantly share code, notes, and snippets.

@mzaks
Created April 26, 2015 11:52
Show Gist options
  • Save mzaks/3ec240b6d078e7b44102 to your computer and use it in GitHub Desktop.
Save mzaks/3ec240b6d078e7b44102 to your computer and use it in GitHub Desktop.
func measureArray(){
let time = NSDate()
var a = [0]
for i in 1...1_000{
a.append(i)
}
let after = NSDate()
println("\(after.timeIntervalSince1970 - time.timeIntervalSince1970) Array 1K")
}
func measureList(){
let time = NSDate()
var a = 0 => nil
for i in 1...1_000{
a = i => a
}
let after = NSDate()
println("\(after.timeIntervalSince1970 - time.timeIntervalSince1970) List 1K")
}
measureArray() // 0.000458955764770508 Array 1K
measureList() // 0.306179046630859 List 1K
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment