[swift-users] Huge difference in speed in Array<Class>/Array<Struct> on OSX/Ubuntu platform with same? toolchain
Joe Groff
jgroff at apple.com
Fri Jan 29 14:55:11 CST 2016
> On Jan 29, 2016, at 11:32 AM, Trent Nadeau <tanadeau at gmail.com> wrote:
>
> I haven't looked at the bridging code yet, but is it possible that the overhead could only be incurred on the first conversion to NSArray? That way if you don't use that functionality it's consistent across platforms, and if you do use it, you get an initial O(n) hit and then O(1) afterwards.
Dave Abrahams can probably elaborate on the history better than me, but the current design balances a number of considerations. Microbenchmarks tend to be poor indicators of real-world performance, and in most Cocoa application code, arrays are shuttled into and out of Cocoa pretty frequently, so forcing every index read operation to do a deep conversion was unacceptable.
-Joe
More information about the swift-users
mailing list