The Computer Language
Benchmarks Game

Swift versus Java fastest programs

by faster benchmark performance

mandelbrot
source secs mem gz cpu cpu load
Swift 3.30 39,048 1136 13.09 99% 99% 99% 100%
Java 6.96 76,748 796 27.07 98% 98% 96% 98%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 9.98 7,596 1102 39.50 99% 98% 100% 100%
Java 17.91 31,560 1282 70.25 99% 98% 99% 97%
pidigits
source secs mem gz cpu cpu load
Swift 1.76 8,492 601 1.76 1% 100% 1% 0%
Java 3.13 37,324 938 3.35 98% 5% 3% 3%
binary-trees
source secs mem gz cpu cpu load
Swift 5.11 190,716 1001 14.24 100% 62% 59% 60%
Java 8.28 982,224 835 27.19 79% 86% 83% 83%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.96 7,892 601 15.75 100% 100% 99% 100%
Java 4.27 32,960 950 16.41 95% 97% 98% 96%
n-body
source secs mem gz cpu cpu load
Swift 21.80 16,264 1357 21.79 1% 0% 1% 100%
Java 22.00 32,496 1489 22.07 1% 100% 0% 1%
reverse-complement
source secs mem gz cpu cpu load
Swift 3.76 770,644 1287 4.44 38% 2% 0% 80%
Java 3.31 626,956 2183 7.44 56% 60% 83% 45%
fasta
source secs mem gz cpu cpu load
Swift 2.79 8,504 1953 4.38 4% 96% 43% 18%
Java 2.32 42,556 2473 6.24 73% 85% 49% 63%
k-nucleotide
source secs mem gz cpu cpu load
Swift 28.42 261,568 1366 109.98 96% 96% 96% 99%
Java 8.66 385,768 1812 26.52 76% 81% 74% 76%
regex-redux
source secs mem gz cpu cpu load
Swift 73.35 883,632 715 140.42 56% 38% 61% 42%
Java 10.52 637,380 929 31.89 75% 80% 77% 72%
Swift

Swift version 4.2 (swift-4.2-RELEASE)
Target: x86_64-unknown-linux-gnu
LLVM version 5.0.1

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)