frol / completely-unscientific-benchmarks

Naive performance comparison of a few programming languages (JavaScript, Kotlin, Rust, Swift, Nim, Python, Go, Haskell, D, C++, Java, C#, Object Pascal, Ada, Lua, Ruby)
Apache License 2.0
547 stars 68 forks source link

add unmanaged swift benchmark based on naive algorithm #76

Closed jgh- closed 5 years ago

jgh- commented 5 years ago

This also adds a Package.swift so that you can build multiple benchmarks at once using swift build and updates the random function so that it can be built on both Linux and macOS.

I see about a 3.5x speedup on macOS using unmanaged vs managed. It's possible this could be further tuned - using loops instead of recursion and other tricks to squeeze out more performance but I think just turning off arc results in a much larger performance increase than other strategies would.

frol commented 5 years ago

@jgh- Thank you for your contribution! I am sorry it took so long, I didn't have the bandwidth to manage it.

The performance on the laptop that all the previous benchmarks were done is the following:

NOTE: It seems that Swift 5.0 produced the binary that is slightly slower than Swift 4.1