Created
October 27, 2018 21:08
-
-
Save Joannis/bc63701ea334430b03031414e93c634f to your computer and use it in GitHub Desktop.
Code using the Any type
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
| import Foundation | |
| let date = Date() | |
| var array = [Any]() | |
| for _ in 0..<100_000 { | |
| array.append("Hello, world") | |
| } | |
| var array2 = [Any]() | |
| for _ in 0..<100_000 { | |
| array2.append(array.removeLast()) | |
| } | |
| print(Date().timeIntervalSince(date)) | |
| print(array2.count) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
59ms on debug, 11ms on release both rounded to nearest the ms (rounded down)
If you replace
AnywithStringit becomes:28ms on debug and 4 ms both rounded to nearest the ms (up)