[swift-users] problems with simple binary-trees program

Janosch Hildebrand jnosh at jnosh.com
Sun Dec 20 10:12:22 CST 2015


> On 20 Dec 2015, at 08:48, Isaac Gouy via swift-users <swift-users at swift.org> wrote:
> 
> On Saturday, December 19, 2015 2:39 PM, David Turnbull <dturnbull at gmail.com> wrote:
> 
>> Winners of this test have pooled memory (apr_pools) and tail recursion.
> 
> 
> A simple Swift program that completed the workloads within an hour time-out would be an incredible improvement :-)
> 
> Instead of looking at the "Winners" compare with the TypeScript program
> 
> http://benchmarksgame.alioth.debian.org/u64q/program.php?test=binarytrees‚ü®=typescript&id=2
> 
> Why does a Swift transliteration of that program perform so slowly?

In one word: ARC.
This is pretty much a worst case example for ARC and the execution time is basically just ARC overhead.

To make this faster you'd have to improve on this.
The "simplest" solution would be to simply use UnsafePointers instead of classes or indirect enums.
Basically just rewrite a C example in Swift; not pretty but it should also perform very much like C then.

> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

- Janosch



More information about the swift-users mailing list