The Computer Language
Benchmarks Game

Swift programs versus Java

by benchmark task performance

mandelbrot
source secs mem gz cpu cpu load
Swift 3.31 39,544 1136 13.09 99% 99% 100% 99%
Java 6.04 76,528 796 23.34 98% 97% 97% 97%
pidigits
source secs mem gz cpu cpu load
Swift 1.76 8,932 601 1.75 100% 2% 1% 2%
Java 3.12 36,788 938 3.31 6% 3% 4% 96%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 10.08 7,920 1102 39.91 98% 100% 98% 100%
Java 17.26 32,116 1282 67.75 98% 99% 97% 99%
binary-trees
source secs mem gz cpu cpu load
Swift 4.98 190,896 1001 14.01 61% 100% 63% 60%
Java 8.34 893,008 835 28.20 87% 79% 96% 81%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.97 9,684 601 15.81 100% 100% 100% 100%
Java 4.23 34,472 950 16.27 96% 97% 97% 96%
reverse-complement
source secs mem gz cpu cpu load
Swift 1.00 285,556 1287 1.18 80% 1% 36% 2%
Java 1.03 191,064 2183 2.31 52% 57% 43% 74%
n-body
source secs mem gz cpu cpu load
Swift 21.96 7,452 1253 21.95 0% 1% 100% 0%
Java 22.10 33,136 1429 22.20 31% 1% 1% 70%
fasta
source secs mem gz cpu cpu load
Swift 2.41 32,480 2096 8.07 78% 86% 90% 81%
Java 2.33 43,924 2473 6.07 53% 71% 63% 74%
k-nucleotide
source secs mem gz cpu cpu load
Swift 20.55 193,992 1366 76.16 91% 97% 92% 91%
Java 8.70 375,568 1812 27.17 80% 72% 74% 88%
regex-redux
source secs mem gz cpu cpu load
Swift 74.22 898,456 715 137.84 2% 86% 100% 3%
Java 10.34 627,224 929 29.88 74% 72% 65% 79%
Swift

Swift version 4.1-dev (LLVM 3fa7aed3df, Clang 529966cf07, Swift 607f23d66d)
Target: x86_64-unknown-linux-gnu

Java

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