The Computer Language
Benchmarks Game

Swift programs versus Java

by benchmark task performance

binary-trees
source secs mem gz cpu cpu load
Swift 4.88 192,428 997 13.77 91% 61% 69% 63%
Java 11.26 593,156 835 39.02 85% 88% 90% 88%
mandelbrot
source secs mem gz cpu cpu load
Swift 3.32 41,236 1136 13.17 99% 99% 99% 100%
Java 7.10 90,588 796 27.92 99% 99% 98% 98%
pidigits
source secs mem gz cpu cpu load
Swift 1.75 8,128 601 1.74 1% 0% 100% 1%
Java 3.06 31,760 938 3.16 6% 3% 97% 1%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 10.34 9,656 1102 40.92 100% 100% 98% 98%
Java 13.74 30,368 1282 54.12 100% 98% 98% 99%
reverse-complement
source secs mem gz cpu cpu load
Swift 0.85 273,548 1287 1.03 10% 13% 80% 22%
Java 1.10 345,352 1661 2.40 33% 82% 53% 54%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.99 13,404 601 15.82 99% 100% 99% 99%
Java 4.29 29,884 950 16.56 96% 97% 99% 95%
n-body
source secs mem gz cpu cpu load
Swift 23.62 7,256 1253 23.61 1% 1% 100% 0%
Java 21.54 27,092 1489 21.56 1% 1% 100% 1%
fasta
source secs mem gz cpu cpu load
Swift 2.36 37,188 2096 7.26 89% 82% 73% 66%
Java 2.13 36,036 2457 5.66 94% 58% 59% 60%
k-nucleotide
source secs mem gz cpu cpu load
Swift 20.64 264,112 1366 76.31 93% 90% 96% 92%
Java 7.93 465,372 1802 25.11 75% 75% 75% 93%
regex-redux
source secs mem gz cpu cpu load
Swift 101.01 695,648 671 100.95 84% 17% 1% 0%
Java 12.31 902,528 929 38.75 73% 76% 86% 81%
Swift

Swift version 3.1-dev (LLVM 90ddc086b8, Clang 38e310f953, Swift 66d9533723)
Target: x86_64-unknown-linux-gnu

Java

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)