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 38,896 1136 13.09 99% 99% 99% 100%
Java 6.96 76,316 796 27.06 97% 97% 97% 97%
pidigits
source secs mem gz cpu cpu load
Swift 1.76 8,368 601 1.76 0% 100% 0% 1%
Java 3.13 37,376 938 3.35 1% 98% 4% 6%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 10.16 7,628 1102 40.15 98% 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.12 190,820 1001 14.38 63% 60% 60% 100%
Java 8.39 960,056 835 27.39 81% 85% 74% 90%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.97 7,880 601 15.79 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 21.80 18,344 1357 21.79 100% 1% 1% 0%
Java 22.00 32,272 1489 22.07 1% 0% 0% 100%
reverse-complement
source secs mem gz cpu cpu load
Swift 3.73 785,980 1287 4.41 3% 6% 76% 38%
Java 3.32 609,712 2183 7.54 64% 44% 44% 76%
fasta
source secs mem gz cpu cpu load
Swift 2.77 8,584 1953 4.35 79% 24% 48% 4%
Java 2.32 42,212 2473 6.30 65% 85% 47% 76%
k-nucleotide
source secs mem gz cpu cpu load
Swift 29.06 261,872 1366 112.27 96% 96% 96% 99%
Java 8.74 470,116 1812 27.12 71% 73% 93% 74%
regex-redux
source secs mem gz cpu cpu load
Swift 74.94 891,392 715 143.53 52% 1% 100% 41%
Java 10.50 571,736 929 31.63 71% 73% 66% 92%
Swift

Swift version 4.2.1-dev (LLVM 4ba03d9389, Clang 78aa734eee, Swift f4134ebef6)
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)