Created
April 26, 2015 11:52
-
-
Save mzaks/3ec240b6d078e7b44102 to your computer and use it in GitHub Desktop.
This file contains 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 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