[swift-users] Huge difference in speed in Array<Class>/Array<Struct> on OSX/Ubuntu platform with same? toolchain

Sergey Kuratov ksubox.swift at gmail.com
Fri Jan 29 21:12:49 CST 2016


Basically I understand what's going on (especially from Instruments), but
question is not about implementation.
I'm speaking about UNIFORM behaviour for all platform (actually I guess we
will see Windows/Android and so on ports).
So Array on Linux should work as Array on OSX, Windows, Android, ....
If we need specific OS behaviour we should make specific class like
ObjcArray<Class>, .... Isn't it right way ?
Or at least in language guide should be written "Use Array only if you need
to interact with ObjC runtime..." and of course same about all other ObjC
classes. Right ?


On Sat, Jan 30, 2016 at 5:55 AM, Joe Groff <jgroff at apple.com> wrote:

>
> > 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160130/44095815/attachment.html>


More information about the swift-users mailing list