Why Swift is 100 times slower than C in this image processing test? [duplicate] Why Swift is 100 times slower than C in this image processing test? [duplicate] c c

Why Swift is 100 times slower than C in this image processing test? [duplicate]


Building with:

xcrun swift -Ofast test.swift -o test

I'm getting times of:

real    0m0.052suser    0m0.009ssys 0m0.005s


Let's just concentrate on the answer to the question, which started with a "Why": Because you didn't turn optimisations on, and Swift relies heavily on compiler optimisation.

That said, doing image processing in C is truly daft. That's what you have CGImage and friends for.