0

My Xcode project takes ages to build so I have looked at expression that takes a long time.

The line

let timeStamp = Int(Date().timeIntervalSince1970)

takes 110ms. I have tried

let timeStamp : Int = Int(Date().timeIntervalSince1970)

which doesn't help. What else can I do to speed up Int casts or am I doing something wrong?

Also, UInt8 to Int takes a lot of time and Int to Int64 too. Basically everything that has to do with an Int takes a lot of time. Even Strings seem to be less compile-hungry.

Another example is

let t = CGFloat(Float(arc4random()) / Float(UINT32_MAX)) - 56ms

Trangler
  • 73
  • 5
  • How old is your computer? Why are you using NSDate instead of Date? – EmilioPelaez Jun 30 '20 at 23:01
  • MacBook Pro from 2017. Switched to `Date` but it's not much different unfortunately – Trangler Jun 30 '20 at 23:05
  • See also: https://stackoverflow.com/q/62641269/3141234 Particularly, I feel my comment is worth repeating: "Just a word of caution: unless compile times are a huge concern for you, don't chase this dragon too far. You'll end up using less and less type inference, adding tons of type information to your code that only clutters it, only for some ms of compilation gain. Considering almost all builds are incremental and only involve a few files, it's usually not too big of a deal " – Alexander Jul 01 '20 at 00:13

0 Answers0