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.19 39,296 1138 12.65 99% 99% 100% 99%
Java 6.83 79,108 796 26.86 97% 99% 99% 99%
pidigits
source secs mem gz busy cpu load
Swift 1.75 8,828 600 1.78 2% 0% 1% 99%
Java 3.07 39,320 938 3.31 2% 5% 3% 98%
fannkuch-redux
source secs mem gz busy cpu load
Swift 10.01 7,436 1097 39.63 99% 98% 100% 100%
Java 14.33 34,888 1282 56.56 99% 98% 99% 98%
spectral-norm
source secs mem gz busy cpu load
Swift 3.96 8,000 601 15.79 100% 100% 100% 100%
Java 4.22 36,948 950 16.43 98% 97% 98% 96%
n-body
source secs mem gz busy cpu load
Swift 22.03 12,160 1355 22.25 0% 0% 100% 1%
Java 21.93 35,408 1429 22.44 1% 0% 100% 1%
reverse-complement
source secs mem gz busy cpu load
Swift 3.84 720,884 1286 4.61 2% 1% 81% 36%
Java 3.16 712,368 2183 7.08 65% 47% 42% 70%
fasta
source secs mem gz busy cpu load
Swift 3.02 8,720 1945 4.64 20% 39% 47% 48%
Java 2.22 45,172 2473 5.99 61% 50% 98% 60%
k-nucleotide
source secs mem gz busy cpu load
Swift 21.98 257,192 1367 83.02 93% 94% 93% 97%
Java 9.33 447,976 1812 29.36 73% 83% 82% 77%
regex-redux
source secs mem gz busy cpu load
Swift 44.49 881,444 715 80.43 26% 92% 1% 62%
Java 10.31 644,560 740 31.47 72% 72% 92% 70%
binary-trees
source secs mem gz busy cpu load
Swift 37.86 702,792 816 119.21 100% 76% 78% 60%
Java 8.32 953,620 835 28.37 95% 87% 81% 77%
Swift

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

Java

openjdk 13 2019-09-17
OpenJDK Runtime Environment (build 13+33)
OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)