Re: Is Swift really swift?
Re: Is Swift really swift?
- Subject: Re: Is Swift really swift?
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Wed, 09 Jul 2014 09:09:56 +0700
On 6 Jul 2014, at 23:02, Gerriet M. Denkmann <email@hidden> wrote:
>
> On 6 Jul 2014, at 03:23, Jens Alfke <email@hidden> wrote:
>
>>
>> On Jul 5, 2014, at 12:48 PM, Gerriet M. Denkmann <email@hidden> wrote:
>>
>>> Using maskArray took 15 sec. This is 160 times slower than computing directly: 0.09 sec (1.25 slower than Obj-C).
>>
>> . Have you tried CFBitVector?
>
> Using Time Profiler in Instruments I have found that my Obj-C version uses
> 4616 ms for the main function + CFBitVector functions
>
> Swift uses about the same: 4778 ms
> To be added: 172 ms for stuff which was just a #define in Obj-C
>
>
> But then there is a huge difference in overhead:
> Obj-C has just 5 ms for CFRelease
>
> But Swift has:
> 10258 ms for CFRelease, CFRetain, objc_release, objc_retain, -[NSObject retain], -[__NSCFType retain], objc_msgSend etc.
>
> Finally also 139 ms for convertBoolToObjCBool and back
>
> If someone is interested in looking at this code: I am very willing to share it.
> It is not very big - about 200 lines per version.
>
> Maybe there is some obvious mishandling of Swift in my code. My experience with Swift is less than a week.
The setup is:
App in Obj-C works with Swift Class.
Now I changed the Swift Class talking with the rest of the app (which needs to be a subclass of NSObject) to do just the interfacing, and moved the real calculations into a new Swift class (no subclass of NSObject).
By this I got a twofold speed increase.
Before this, Swift was more than 3 times slower, now it is less than 1.5 times slower than the equivalent Obj-C code.
Lesson learned: Swift inter-operates with Obj-C at quite a hight cost.
Gerriet.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden