10x worse Swift performance due to Obj-C bridging in framework?

ぐ巨炮叔叔 提交于 2020-01-24 00:01:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!