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,128 601 1.74 1% 0% 100% 1%
C++ g++ 1.89 3,868 508 1.89 100% 1% 2% 1%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 10.34 9,656 1102 40.92 100% 100% 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.85 273,548 1287 1.03 10% 13% 80% 22%
C++ g++ 0.60 211,852 2275 0.98 38% 25% 82% 27%
fasta
source secs mem gz cpu cpu load
Swift 2.36 37,188 2096 7.26 89% 82% 73% 66%
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,236 1136 13.17 99% 99% 99% 100%
C++ g++ 1.73 34,064 1002 6.80 98% 98% 98% 99%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.99 13,404 601 15.82 99% 100% 99% 99%
C++ g++ 1.99 1,880 1044 7.89 100% 99% 99% 99%
binary-trees
source secs mem gz cpu cpu load
Swift 4.88 192,428 997 13.77 91% 61% 69% 63%
C++ g++ 2.36 114,404 809 7.69 86% 71% 87% 85%
n-body
source secs mem gz cpu cpu load
Swift 23.62 7,256 1253 23.61 1% 1% 100% 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.64 264,112 1366 76.31 93% 90% 96% 92%
C++ g++ 7.18 164,052 1252 24.28 83% 83% 93% 83%
regex-redux
source secs mem gz cpu cpu load
Swift 101.01 695,648 671 100.95 84% 17% 1% 0%
C++ g++ 17.14 220,088 853 25.22 95% 3% 51% 1%
Swift

Swift version 3.1-dev (LLVM 90ddc086b8, Clang 38e310f953, Swift 66d9533723)
Target: x86_64-unknown-linux-gnu

C++ g++

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