12 ms·
And it is fast. I clocked it at over 200K lines/sec. Swift, on a typical project, will do around 20. Not K, just lines/sec. Of course the C code was a lot s
by mpweiher 8y ago
And it is fast. I clocked it at over 200K lines/sec. Swift, on a typical project, will do around 20. Not K, just lines/sec.
Of course the C code was a lot simpler, but still...
- appcypher 8y agoI would like to know how you were able to investigate that.
- jacobush 8y agoHit compile, count the seconds until complete?
- fdej 8y agoWait, what? 50 milliseconds per line of code? How is that even possible?
- abecedarius 8y agoNot 50 milliseconds, 5 microseconds. Something like 10,000 cycles, or a few hundred to a thousand cycles per byte of source code (depending on average line length).
- fdej 8y ago"around 20. Not K, just lines/sec"
- abecedarius 8y agoSorry for the misunderstanding. Inefficiencies on that level just aren't very surprising to me anymore.
- opencl 8y agoIt is heavily dependent on the type of code you write. For example, ternary operators can take several hundreds of milliseconds or even entire seconds each to compile while an equivalent if statement is orders of magnitude faster[1]. Anything with type inference also tends to compile very slowly. [1] https://bugs.swift.org/browse/SR-1577 https://bugs.swift.org/browse/SR-1577
- mpweiher 8y agoMakes you wonder, right? Of course, there are (still) pathological cases where a single line of code will abort because it runs out of time. > cat too-complex.swift let a:[Int] = [1] + [2] + [3] + [4] + [5] + [6] + [7] For me, this aborts after about a minute and a half: > time swiftc too-complex.swift too-complex.swift:1:49: error: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions let a:[Int] = [1] + [2] + [3] + [4] + [5] + [6] + [7] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ real 1m35.094s user 1m16.698s sys 0m5.141s That appears to be some sort of exponential in type inference. Other similar ones have been fixed. The ternary expressions mentioned elsewhere also appear to be problematic, and in general, there's little time bombs all over just waiting to go off. The rate I mentioned earlier was taken from a CocoaHeads talk by someone who built a caching mechanism for Carthage, because their Swift framework(s) of around 20KLOC were taking ages to compile. So it's a real-world example, not something made up.
- munificent 8y ago> That appears to be some sort of exponential in type inference. If I recall, it's in the implicit conversions, not strictly the type inference.
- IncRnd 8y agoSwift, on a typical project, will do around 20. Not K, just lines/sec. To compare a historical compiler with your Swift numbers: In 1989, Turbo C compiled 16K lines per minute on a ho-hum machine. The computers today, 30 years later, are more than 60x faster, so one would expect compilation speeds exceeding 16k per second of swift code. Turbo Pascal compiled about twice as fast as Turbo C at the time.
- vintagedave 8y agoDelphi (Turbo Pascal's successor) today does a million in four seconds, or about 250k / sec. https://youtu.be/Yq2mNUzcpE0?t=146 https://youtu.be/Yq2mNUzcpE0?t=146
- IncRnd 8y agoThat's four orders of magnitude greater than 20 loc/sec.
- AboutTheWhisles 8y ago60x faster? Today's computers are closer to 1000x faster.
- IncRnd 8y agoThat was my point. There are 60 seconds in a minute.
- dxhdr 8y ago> Swift, on a typical project, will do around 20. Not K, just lines/sec. Wow, how common is this in practice? That sounds broken.