Get the latest tech news
Swift's native Clocks are inefficient
By which I mean, things like ContinuousClock and SuspendingClock. In absolute terms they don’t have much overhead – think sub-microsecond for most uses.
I stumbled into this because of a fairly common and otherwise uninteresting pattern – throttling UI updates on an I/O operation’s progress. That’s a lot of time wasted in function calls and struct initialisation and type conversion and protocol witnesses and all that guff. This surprised me because it has the overhead of at least one Objective-C message send (for timeIntervalSinceNow), unless somehow the Swift compiler is optimising that into a static function call, or inlining it entirely…?
Or read this on Hacker News