Skip to content

Instantly share code, notes, and snippets.

@Catfish-Man
Created November 20, 2021 00:11
Show Gist options
  • Save Catfish-Man/2b93e32f5fcb883e80e51786c4f52207 to your computer and use it in GitHub Desktop.
Save Catfish-Man/2b93e32f5fcb883e80e51786c4f52207 to your computer and use it in GitHub Desktop.
import Foundation
func test() {
let object = NSObject()
let cocoa = NSMutableArray()
var swift = Array<AnyObject>()
var start = Date()
for _ in 1 ... 200_000 {
cocoa.insert(object, at: 0)
}
var elapsed = -(start.timeIntervalSinceNow)
print("Cocoa took \(elapsed) seconds to prepend 200k objects")
start = Date()
for _ in 1 ... 200_000 {
swift.insert(object, at: 0)
}
elapsed = -(start.timeIntervalSinceNow)
print("Swift took \(elapsed) seconds to prepend 200k objects")
}
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment