问题
I'm working on a performance-intensive Swift app, with most of the fast code residing inside a framework. One of my expensive functions involves iterating over a two-million element array of structs. Unfortunately, the Obj-C bridge makes Swift Array performance about an order of magnitude slower than it should be. About 90% of my cycles are wasted on _ArrayBuffer._checkInoutAndNativeTypeCheckedBounds
and bridging-related retains and releases. If I drop the framework and simply include those same files as part of my target, performance improves 10x. However, I'd prefer to keep the framework around if possible.
Is there any way to tell my frameworks not to do any Obj-C bridging, i.e. just use straight Swift?
来源:https://stackoverflow.com/questions/46833459/10x-worse-swift-performance-due-to-obj-c-bridging-in-framework