The Computer Language
Benchmarks Game

Swift programs versus Java

by benchmark task performance

mandelbrot
source secs mem gz cpu cpu load
Swift 3.32 41,748 1136 13.19 100% 99% 99% 99%
Java 6.08 77,056 796 23.61 97% 97% 99% 97%
pidigits
source secs mem gz cpu cpu load
Swift 1.75 8,532 601 1.75 100% 1% 1% 0%
Java 3.12 37,444 938 3.30 2% 5% 98% 4%
binary-trees
source secs mem gz cpu cpu load
Swift 4.96 192,596 997 13.89 60% 63% 61% 99%
Java 8.58 966,808 835 28.98 86% 84% 90% 81%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 10.20 9,784 1102 40.28 100% 99% 98% 98%
Java 15.09 34,764 1282 59.26 99% 98% 98% 100%
reverse-complement
source secs mem gz cpu cpu load
Swift 0.86 210,216 1287 1.03 79% 2% 1% 42%
Java 1.13 199,672 2124 2.76 48% 74% 70% 54%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.98 11,292 601 15.82 100% 100% 100% 100%
Java 4.25 36,364 950 16.30 97% 96% 95% 97%
n-body
source secs mem gz cpu cpu load
Swift 21.96 7,396 1253 21.95 1% 100% 1% 0%
Java 22.56 35,208 1424 22.65 99% 1% 1% 1%
fasta
source secs mem gz cpu cpu load
Swift 2.32 34,356 2096 7.62 76% 79% 83% 93%
Java 2.32 46,816 2457 6.37 61% 60% 96% 60%
k-nucleotide
source secs mem gz cpu cpu load
Swift 20.73 246,548 1366 76.47 94% 94% 90% 92%
Java 8.38 375,988 1802 26.25 73% 97% 70% 74%
regex-redux
source secs mem gz cpu cpu load
Swift 75.47 882,900 715 141.92 90% 2% 1% 100%
Java 10.38 634,548 929 29.48 70% 64% 69% 82%
Swift

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

Java

java 9
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)