Created
November 20, 2021 00:11
-
-
Save Catfish-Man/2b93e32f5fcb883e80e51786c4f52207 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
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