The Computer Language
Benchmarks Game

Swift programs versus C++ g++

by benchmark task performance

pidigits
source secs mem gz cpu cpu load
Swift 1.76 8,932 601 1.75 100% 2% 1% 2%
C++ g++ 1.88 4,276 513 1.88 0% 100% 1% 0%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 10.08 7,920 1102 39.91 98% 100% 98% 100%
C++ g++ 10.61 2,044 980 41.90 100% 96% 100% 100%
reverse-complement
source secs mem gz cpu cpu load
Swift 1.00 285,556 1287 1.18 80% 1% 36% 2%
C++ g++ 0.64 247,800 2280 1.03 89% 22% 31% 30%
fasta
source secs mem gz cpu cpu load
Swift 2.41 32,480 2096 8.07 78% 86% 90% 81%
C++ g++ 1.49 4,372 2324 5.28 89% 88% 90% 90%
binary-trees
source secs mem gz cpu cpu load
Swift 4.98 190,896 1001 14.01 61% 100% 63% 60%
C++ g++ 2.55 135,568 809 7.99 85% 96% 69% 66%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.97 9,684 601 15.81 100% 100% 100% 100%
C++ g++ 2.02 1,332 1044 7.91 99% 99% 99% 99%
mandelbrot
source secs mem gz cpu cpu load
Swift 3.31 39,544 1136 13.09 99% 99% 100% 99%
C++ g++ 1.64 27,636 1002 6.51 100% 99% 100% 99%
k-nucleotide
source secs mem gz cpu cpu load
Swift 20.55 193,992 1366 76.16 91% 97% 92% 91%
C++ g++ 7.75 165,180 1276 26.02 80% 96% 82% 79%
n-body
source secs mem gz cpu cpu load
Swift 21.96 7,452 1253 21.95 0% 1% 100% 0%
C++ g++ 8.23 1,856 1763 8.23 100% 1% 1% 0%
regex-redux
source secs mem gz cpu cpu load
Swift 74.22 898,456 715 137.84 2% 86% 100% 3%
C++ g++ 1.61 203,572 1315 4.18 100% 52% 57% 54%
Swift

Swift version 4.1-dev (LLVM 3fa7aed3df, Clang 529966cf07, Swift 607f23d66d)
Target: x86_64-unknown-linux-gnu

C++ g++

g++ (Ubuntu 7.2.0-8ubuntu3) 7.2.0