The Computer Language
Benchmarks Game

Swift versus Java fastest programs

by faster benchmark performance

mandelbrot
source secs mem gz cpu cpu load
Swift 3.30 38,932 1136 13.09 99% 99% 100% 99%
Java 6.13 76,876 796 23.60 96% 96% 96% 97%
pidigits
source secs mem gz cpu cpu load
Swift 1.76 8,448 601 1.76 6% 0% 1% 93%
Java 3.14 37,080 938 3.35 4% 4% 1% 98%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 10.04 7,616 1102 39.74 100% 100% 99% 98%
Java 17.74 31,900 1282 69.78 99% 98% 99% 98%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.95 7,884 601 15.75 100% 100% 100% 100%
Java 4.41 35,028 950 16.79 96% 97% 98% 95%
n-body
source secs mem gz cpu cpu load
Swift 22.28 7,388 1253 22.27 0% 1% 100% 0%
Java 22.19 33,272 1489 22.28 35% 2% 66% 1%
fasta
source secs mem gz cpu cpu load
Swift 2.77 8,592 1953 4.35 77% 71% 7% 6%
Java 2.29 43,724 2473 6.16 67% 76% 59% 70%
k-nucleotide
source secs mem gz cpu cpu load
Swift 29.69 169,780 1231 112.06 99% 93% 93% 93%
Java 8.66 384,756 1812 26.91 69% 88% 81% 75%
reverse-complement
source secs mem gz cpu cpu load
Swift   Failed
Java 0.31 1,028 2183 0.49 68% 35% 24% 52%
regex-redux
source secs mem gz cpu cpu load
Swift   Failed
Java 0.65 45,356 929 2.01 73% 88% 77% 75%
binary-trees
source secs mem gz cpu cpu load
Swift   Failed
Java 0.27 948 835 0.46 74% 44% 21% 42%
Swift

Swift version 4.2-dev (LLVM da1c9a3ae4, Clang 78aa734eee, Swift a710c2f169)
Target: x86_64-unknown-linux-gnu

Java

java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)