The Computer Language
Benchmarks Game

Swift programs versus C++ g++

by benchmark task performance

mandelbrot
source secs mem gz cpu cpu load
Swift 3.22 40,340 1136 12.76 99% 99% 100% 99%
C++ g++ 5.82 33,952 726 22.40 96% 95% 95% 100%
pidigits
source secs mem gz cpu cpu load
Swift 1.75 7,396 601 1.74 1% 1% 100% 0%
C++ g++ 1.89 3,740 508 1.89 2% 99% 0% 2%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 11.44 6,900 1102 45.27 100% 100% 98% 98%
C++ g++ 10.58 2,520 950 41.88 100% 100% 99% 98%
reverse-complement
source secs mem gz cpu cpu load
Swift 0.94 285,740 1287 1.12 54% 0% 47% 21%
C++ g++ 0.59 217,564 2275 0.84 26% 78% 12% 34%
fasta
source secs mem gz cpu cpu load
Swift 2.40 32,536 2096 7.26 78% 81% 72% 73%
C++ g++ 1.47 9,484 2291 5.13 88% 88% 87% 88%
binary-trees
source secs mem gz cpu cpu load
Swift 5.55 247,508 1062 16.74 65% 74% 70% 95%
C++ g++ 3.36 158,320 846 10.59 81% 82% 78% 75%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.97 10,696 601 15.79 100% 100% 100% 100%
C++ g++ 2.01 1,792 1044 8.00 100% 100% 100% 100%
n-body
source secs mem gz cpu cpu load
Swift 23.59 4,336 1253 23.58 0% 100% 1% 0%
C++ g++ 9.30 1,712 1763 9.29 100% 1% 1% 0%
k-nucleotide
source secs mem gz cpu cpu load
Swift 20.48 263,288 1366 75.71 91% 99% 91% 91%
C++ g++ 7.15 164,080 1252 24.21 82% 83% 80% 96%
regex-redux
source secs mem gz cpu cpu load
Swift 97.48 694,832 671 97.43 1% 100% 0% 1%
C++ g++ 6.75 183,256 700 9.80 100% 39% 8% 0%
Swift Swift version 3.1-dev (LLVM a7c680da51, Clang 9772bf511a, Swift 00b540bfbb)
Target: x86_64-unknown-linux-gnu
swift-3.1-DEVELOPMENT-SNAPSHOT-2017-03-13-a-ubuntu16.04
C++ g++

g++ (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609