Apple claims that Swift is 3.9x faster then Python. I’ve run some tests to check if it’s true.
I wrote the same QuickSort algorithm in C++, Swift and Python and then I run it for 100000 element random array on Core 2 Duo iMac. The results are
– 0.287s in c++
– 1.448s in Python
– 40.856s in Swift
I’m a little bit less in love after this tests.
It seems that Xcode can’t compile software or I don’t know how to use it. I’ve done the same test for 1000000 element array but without printing the result and I compiled it in terminal with -Ofast flag. Here is what I’ve got:
– 0.409s in C++
– 1.460s in Python
– 0.412s in Swift
So now I can be in love with Swift once again. Apple was actually right claiming that it is about 4x faster then Python.