The Computer Language
Benchmarks Game

Swift versus C++ g++ fastest programs

Always look at the source code.

These are only the fastest programs. Do some of them use manually vectorized SIMD? Look at the other programs. They may seem more-like a fair comparison to you.

pidigits
source secs mem gz busy cpu load
Swift 0.89 9,256 600 0.91 3% 0% 0% 99%
C++ g++ 0.66 5,152 986 2.63 100% 100% 100% 100%
mandelbrot
source secs mem gz busy cpu load
Swift 1.34 41,120 1140 5.34 99% 99% 100% 100%
C++ g++ 0.84 34,780 3542 3.27 99% 98% 98% 96%
fasta
source secs mem gz busy cpu load
Swift 1.41 26,396 2090 4.73 80% 80% 96% 79%
C++ g++ 0.77 2,504 2751 1.52 64% 0% 99% 37%
spectral-norm
source secs mem gz busy cpu load
Swift 1.43 8,144 601 5.68 100% 99% 99% 99%
C++ g++ 0.72 1,192 1044 2.85 99% 99% 100% 100%
fannkuch-redux
source secs mem gz busy cpu load
Swift 8.24 7,824 1097 32.69 98% 99% 100% 100%
C++ g++ 3.29 1,892 1528 13.06 100% 100% 100% 97%
n-body
source secs mem gz busy cpu load
Swift 5.32 10,456 1365 5.37 100% 0% 0% 0%
C++ g++ 2.12 764 1927 2.17 0% 2% 100% 0%
reverse-complement
source secs mem gz busy cpu load
Swift 1.81 781,992 1286 2.28 3% 0% 48% 75%
C++ g++ 0.52 1,788 1853 0.52 0% 98% 0% 2%
k-nucleotide
source secs mem gz busy cpu load
Swift 13.56 256,964 1367 52.30 96% 95% 96% 99%
C++ g++ 1.93 156,548 1631 5.88 69% 93% 69% 75%
binary-trees
source secs mem gz busy cpu load
Swift 16.15 699,872 862 51.81 77% 66% 79% 100%
C++ g++ 0.94 176,428 1122 3.39 86% 88% 100% 85%
regex-redux
source secs mem gz busy cpu load
Swift 23.14 1,059,096 745 48.76 92% 37% 46% 36%
C++ g++ 1.10 203,924 1315 3.43 63% 77% 71% 100%
Swift

Swift version 5.5-dev (LLVM f9e846e117057c8, Swift a58e8c181f2e258)
Target: x86_64-unknown-linux-gnu

C++ g++

g++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0