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 1.87 39,072 1138 7.44 100% 99% 98% 99%
Java 4.11 68,204 796 16.20 98% 99% 98% 99%
fannkuch-redux
source secs mem gz busy cpu load
Swift 7.46 7,668 1097 29.52 98% 100% 99% 100%
Java 11.00 34,104 1282 43.42 99% 98% 98% 99%
n-body
source secs mem gz busy cpu load
Swift 4.89 10,240 1326 4.95 0% 100% 1% 0%
Java 6.75 35,200 1489 6.83 0% 0% 100% 1%
spectral-norm
source secs mem gz busy cpu load
Swift 1.44 7,960 601 5.73 100% 99% 100% 99%
Java 1.68 38,348 950 6.43 96% 96% 96% 95%
pidigits
source secs mem gz busy cpu load
Swift 0.76 8,428 600 0.82 100% 3% 1% 4%
Java 0.79 35,568 764 0.84 99% 3% 3% 1%
reverse-complement
source secs mem gz busy cpu load
Swift 1.79 788,908 1286 2.25 74% 19% 2% 30%
Java 1.54 702,332 2183 3.55 78% 46% 49% 57%
fasta
source secs mem gz busy cpu load
Swift 1.51 26,104 2090 4.81 91% 76% 77% 74%
Java 1.27 43,968 2473 3.92 73% 95% 70% 70%
k-nucleotide
source secs mem gz busy cpu load
Swift 14.26 256,316 1367 54.61 97% 95% 95% 96%
Java 5.00 408,040 1812 16.36 74% 81% 86% 86%
regex-redux
source secs mem gz busy cpu load
Swift 24.30 1,060,320 745 50.20 44% 92% 35% 35%
Java 5.70 656,328 929 18.25 89% 76% 79% 75%
binary-trees
source secs mem gz busy cpu load
Swift 16.00 699,652 862 50.97 100% 65% 76% 78%
Java 2.50 2,487,096 835 7.90 88% 75% 75% 79%
Swift

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

Java

openjdk 15 2020-09-15
OpenJDK Runtime Environment (build 15+36-1562)
OpenJDK 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)