Swift 1.2 offers significant performance improvements

(Image Credit: Apple Developer)

Apple updated their new programming language, Swift, earlier this week and it promises to "produce binaries that run considerably faster, and new optimizations which deliver even better Release build performance."

Those are bold claims, but ones which we hope are true considering earlier versions of Swift have been anything but quick. As a language still finding its feet, performance issues can be forgiven as long as Apple can move fast to make the improvements it needs which it seems to be doing...

Tyrone, an iOS developer based in Melbourne, runs a blog with some of his latest development musings. He caused a bit of a stir in the developer community a couple of months back for pointing out how slow Swift was compared to Objective-C. In a new post, he compares the latest version of Swift to see whether it's improved as much as Apple claims.

Here are his results: 

Style 

Swift 1.1 

Swift 1.2 

ObjC 

0.09 

0.06 

Swift 

1.42 

0.35 

ObjC-like Swift 

0.29 

0.13 

RubyMotion 

0.21 

0.21 

Whilst not on the same level as Objective-C or even RubyMotion, Swift 1.2 is beginning to reach a point where it can be considered quick like its name suggests. Tyrone didn't make any changes to his code in this second test, and even says: "First thing I noticed after running the tests was that the Objective-C style Swift code which previously segfaulted if compiled with optimisations turned on, would now run just fine with optimisations turned on!"

PrimateLabs, the clever crew behind benchmarking tool GeekBench, took a more-advanced look at Swift 1.1 back in December and ported three Geekbench 3 workloads from C++ to Swift: Mandelbrot, FFT, and GEMM. They did this due to their individual performance characteristics since Mendelbrot is compute-bound, whilst both FFT and GEMM are memory-bound but access large arrays in different ways.

Workload 

Version 

Minimum 

Maximum 

Average 

Mandelbrot 

Swift 

2.15GFlops 

2.43 GFlops 

2.26 GFlops 

 

C++ 

2.25GFlops 

2.38 GFlops 

2.33 GFlops 

GEMM 

Swift 

1.48 GFlops 

1.59 GFlops 

1.53 GFlops 

 

C++ 

8.61 GFlops 

9.92 GFlops 

9.32 GFlops 

FFT 

Swift 

0.10 GFlops 

0.10 GFlops 

0.10 GFlops 

 

C++ 

2.29 GFlops 

2.60 GFlops 

2.42 GFlops 

Mandelbrot gave a respectable performance considering this early-stage of Swift, but FFT and GEMM fell-behind by a large margin. The C++ implementation of GEMM was over 6x faster, whilst the FFT implementation was a concerning 24x faster than performing the same using Swift.

It will be interesting to see whether Geekbench's workloads shows as significant improvements as Tyrone found with his independent Swift 1.2 development. We will be reaching out to the team at PrimateLabs to see if they mind performing their test again with the same hardware, and will update you if newer results are provided.

What do you think of Swift's performance so far? Let us know in the comments.

Related Stories

Leave a comment

Alternatively

This will only be used to quickly provide signup information and will not allow us to post to your account or appear on your timeline.