Created
October 2, 2014 00:18
-
-
Save iosdevzone/18a5bc1ab30de20a5810 to your computer and use it in GitHub Desktop.
File to demonstrate very slow compilation times on swift when string concatenation operator used rather than string interpolation.
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
class Foo | |
{ | |
let a = "a" | |
let b = "b" | |
let c = "c" | |
let values = [ "A", "B", "C", "D", "E" ] | |
var rawValues: String | |
{ | |
let a = self.a | |
let b = self.b | |
let c = self.c | |
var s : String = "static let \(a) = [ " | |
#if false | |
/* | |
real 0m35.143s | |
user 0m29.888s | |
sys 0m0.984s | |
*/ | |
let d : [String] = values.map { $0 + ": " + b + "(" + c + $0 + ")" } | |
#else | |
/* | |
real 0m0.226s | |
user 0m0.136s | |
sys 0m0.059s | |
*/ | |
let d : [String] = values.map { "\($0): \(b)(\(c)\($0))" } | |
#endif | |
var j = join(", \n", d) | |
s += j | |
s += " ]\n" | |
return s | |
} | |
} | |
var f = Foo() | |
println(f.rawValues) | |
/* | |
Model Name: MacBook Air | |
Model Identifier: MacBookAir3,1 | |
Processor Name: Intel Core 2 Duo | |
Processor Speed: 1.4 GHz | |
Number of Processors: 1 | |
Total Number of Cores: 2 | |
L2 Cache: 3 MB | |
Memory: 2 GB | |
Bus Speed: 800 MHz | |
System Version: OS X 10.9.4 (13E28) | |
Kernel Version: Darwin 13.3.0 | |
Boot Volume: New Macintosh HD | |
Boot Mode: Normal | |
Computer Name: inu | |
User Name: idz (idz) | |
Secure Virtual Memory: Enabled | |
Time since boot: 6:21 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment