The Computer Language
Benchmarks Game

Swift versus Java fastest programs

by faster benchmark performance

mandelbrot
source secs mem gz cpu cpu load
Swift 3.23 39,160 1138 12.78 99% 99% 100% 99%
Java 6.96 76,316 796 27.06 97% 97% 97% 97%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 10.32 7,400 1097 40.89 99% 100% 98% 100%
Java 17.98 31,180 1282 70.57 97% 99% 97% 99%
binary-trees
source secs mem gz cpu cpu load
Swift 5.01 195,268 1001 14.04 60% 91% 69% 63%
Java 8.39 960,056 835 27.39 81% 85% 74% 90%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.95 7,856 601 15.75 100% 100% 99% 100%
Java 4.26 33,572 950 16.39 96% 96% 98% 95%
n-body
source secs mem gz cpu cpu load
Swift 22.00 19,948 1355 21.99 1% 100% 0% 0%
Java 22.00 32,272 1489 22.07 1% 0% 0% 100%
fasta
source secs mem gz cpu cpu load
Swift 2.37 33,736 2090 7.12 89% 89% 64% 61%
Java 2.32 42,212 2473 6.30 65% 85% 47% 76%
reverse-complement
source secs mem gz cpu cpu load
Swift 3.74 777,316 1286 4.42 50% 37% 3% 39%
Java 3.32 609,712 2183 7.54 64% 44% 44% 76%
k-nucleotide
source secs mem gz cpu cpu load
Swift 21.35 257,972 1367 80.51 93% 93% 93% 99%
Java 8.74 470,116 1812 27.12 71% 73% 93% 74%
regex-redux
source secs mem gz cpu cpu load
Swift 115.17 897,176 715 209.86 17% 55% 46% 66%
Java 10.50 571,736 929 31.63 71% 73% 66% 92%
pidigits
source secs mem gz cpu cpu load
Swift   Make Error
Java 1.85 ? 938 ? 12% 28% 50% 16%
Swift

Swift version 5.0-dev (LLVM 3207a50965, Clang a113643bc4, Swift d07c25ac16)
Target: x86_64-unknown-linux-gnu
LLVM version 7.0.0

Java

openjdk 11 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)