The Computer Language
Benchmarks Game

Swift versus Java fastest programs

Always look at the source code.

These are only the fastest programs. Do some of them use manually vectorized SIMD? Look at the other programs. They may seem more-like a fair comparison to you.

mandelbrot
source secs mem gz busy cpu load
Swift 2.14 39,228 1138 8.52 99% 99% 100% 99%
Java 4.15 69,136 796 16.29 98% 99% 98% 99%
fannkuch-redux
source secs mem gz busy cpu load
Swift 8.01 7,576 1097 31.78 100% 100% 99% 98%
Java 10.64 35,192 1282 41.91 99% 98% 99% 97%
n-body
source secs mem gz busy cpu load
Swift 5.32 13,444 1326 5.39 0% 0% 100% 1%
Java 6.74 35,844 1489 6.82 1% 100% 1% 0%
spectral-norm
source secs mem gz busy cpu load
Swift 1.43 8,168 601 5.68 99% 100% 99% 99%
Java 1.63 39,304 756 6.22 95% 97% 95% 95%
pidigits
source secs mem gz busy cpu load
Swift 0.89 8,584 600 0.89 0% 0% 0% 100%
Java 0.93 36,552 764 0.98 2% 3% 1% 99%
fasta
source secs mem gz busy cpu load
Swift 1.43 26,128 2090 4.70 78% 78% 95% 78%
Java 1.21 44,620 2543 3.58 89% 75% 65% 68%
reverse-complement
source secs mem gz busy cpu load
Swift 1.82 785,580 1286 2.28 49% 3% 0% 74%
Java 1.54 670,924 2183 3.51 46% 56% 48% 79%
k-nucleotide
source secs mem gz busy cpu load
Swift 13.46 256,584 1367 51.58 94% 99% 95% 96%
Java 4.98 356,904 1812 16.25 78% 76% 96% 76%
regex-redux
source secs mem gz busy cpu load
Swift 23.71 1,060,560 745 49.20 35% 45% 92% 35%
Java 5.58 985,696 929 18.26 81% 77% 84% 85%
binary-trees
source secs mem gz busy cpu load
Swift 15.86 699,612 816 50.77 100% 79% 76% 66%
Java 2.48 1,722,848 835 7.88 98% 75% 71% 74%
Swift

Swift version 5.4-dev (LLVM b6e6f458bb01f1f, Swift 53cfe019c0ce26d)
Target: x86_64-unknown-linux-gnu

Java

openjdk 16 2021-03-16
OpenJDK Runtime Environment (build 16+36-2231)
OpenJDK 64-Bit Server VM (build 16+36-2231, mixed mode, sharing)