The Computer Language
Benchmarks Game

Swift versus Java fastest programs

Always look at the source code.

These are only the fastest programs. Look at the other programs. They may seem more-like a fair comparison to you.

mandelbrot
source secs mem gz busy cpu load
Swift 3.20 39,320 1138 12.68 99% 100% 99% 99%
Java 6.84 76,008 796 26.90 99% 98% 98% 98%
fannkuch-redux
source secs mem gz busy cpu load
Swift 10.08 8,028 1097 39.99 98% 100% 99% 100%
Java 16.12 33,168 1282 63.71 100% 98% 99% 98%
pidigits
source secs mem gz busy cpu load
Swift 1.75 8,716 600 2.05 5% 100% 12% 1%
Java 1.83 34,848 764 1.95 99% 1% 4% 2%
spectral-norm
source secs mem gz busy cpu load
Swift 3.99 7,836 601 15.93 100% 100% 100% 100%
Java 4.15 36,428 950 16.26 98% 100% 98% 97%
n-body
source secs mem gz busy cpu load
Swift 21.74 12,092 1355 22.86 1% 2% 100% 2%
Java 21.85 34,112 1489 22.16 1% 0% 0% 100%
reverse-complement
source secs mem gz busy cpu load
Swift 3.79 753,924 1286 4.83 7% 70% 12% 39%
Java 3.27 714,144 2183 7.54 47% 60% 66% 58%
fasta
source secs mem gz busy cpu load
Swift 2.91 8,524 1945 4.59 18% 62% 63% 14%
Java 2.22 43,096 2473 6.10 67% 83% 45% 80%
k-nucleotide
source secs mem gz busy cpu load
Swift 22.39 257,104 1367 84.59 94% 96% 93% 95%
Java 9.14 403,576 1812 29.10 87% 72% 74% 86%
regex-redux
source secs mem gz busy cpu load
Swift 44.59 885,164 715 81.94 19% 60% 20% 85%
Java 10.27 635,500 740 29.42 74% 81% 55% 76%
binary-trees
source secs mem gz busy cpu load
Swift 38.21 702,592 816 122.34 76% 70% 79% 95%
Java 8.28 948,040 835 28.20 80% 84% 87% 90%
Swift

Swift version 5.1.3 (swift-5.1.3-RELEASE)
Target: x86_64-unknown-linux-gnu

Java

openjdk 14 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)