The Computer Language
Benchmarks Game

Swift programs versus C++ g++

by benchmark task performance

pidigits
source secs mem gz cpu cpu load
Swift 1.75 8,532 601 1.75 100% 1% 1% 0%
C++ g++ 1.89 3,868 508 1.89 100% 1% 2% 1%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 10.20 9,784 1102 40.28 100% 99% 98% 98%
C++ g++ 10.35 2,624 980 40.60 99% 99% 100% 95%
reverse-complement
source secs mem gz cpu cpu load
Swift 0.86 210,216 1287 1.03 79% 2% 1% 42%
C++ g++ 0.60 211,852 2275 0.98 38% 25% 82% 27%
fasta
source secs mem gz cpu cpu load
Swift 2.32 34,356 2096 7.62 76% 79% 83% 93%
C++ g++ 1.48 4,176 2313 5.25 89% 90% 88% 89%
mandelbrot
source secs mem gz cpu cpu load
Swift 3.32 41,748 1136 13.19 100% 99% 99% 99%
C++ g++ 1.73 34,064 1002 6.80 98% 98% 98% 99%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.98 11,292 601 15.82 100% 100% 100% 100%
C++ g++ 1.99 1,880 1044 7.89 100% 99% 99% 99%
binary-trees
source secs mem gz cpu cpu load
Swift 4.96 192,596 997 13.89 60% 63% 61% 99%
C++ g++ 2.36 114,404 809 7.69 86% 71% 87% 85%
n-body
source secs mem gz cpu cpu load
Swift 21.96 7,396 1253 21.95 1% 100% 1% 0%
C++ g++ 9.31 1,052 1544 9.30 1% 1% 1% 100%
k-nucleotide
source secs mem gz cpu cpu load
Swift 20.73 246,548 1366 76.47 94% 94% 90% 92%
C++ g++ 7.18 164,052 1252 24.28 83% 83% 93% 83%
regex-redux
source secs mem gz cpu cpu load
Swift 75.47 882,900 715 141.92 90% 2% 1% 100%
C++ g++ 17.14 220,088 853 25.22 95% 3% 51% 1%
Swift

Swift version 4.0 (swift-4.0-RELEASE)
Target: x86_64-unknown-linux-gnu

C++ g++

g++ (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406