The Computer Language
Benchmarks Game

Swift programs versus Java

by benchmark task performance

binary-trees
source secs mem gz cpu cpu load
Swift 5.47 251,028 1062 16.57 72% 65% 96% 72%
Java 11.52 643,924 889 40.54 89% 92% 85% 89%
mandelbrot
source secs mem gz cpu cpu load
Swift 3.32 42,428 1136 13.17 99% 99% 100% 99%
Java 5.89 89,504 796 23.08 98% 98% 98% 99%
pidigits
source secs mem gz cpu cpu load
Swift 1.75 7,404 601 1.75 100% 1% 1% 2%
Java 3.06 31,088 938 3.16 0% 3% 9% 92%
fannkuch-redux
source secs mem gz cpu cpu load
Swift 11.40 13,216 1102 45.10 100% 100% 98% 98%
Java 17.74 30,048 1282 69.90 98% 98% 100% 99%
reverse-complement
source secs mem gz cpu cpu load
Swift 0.87 274,776 1287 1.05 3% 40% 79% 0%
Java 1.11 345,308 1661 2.44 33% 58% 54% 80%
spectral-norm
source secs mem gz cpu cpu load
Swift 3.97 14,884 601 15.79 100% 100% 99% 100%
Java 4.29 31,428 950 16.56 97% 96% 98% 97%
fasta
source secs mem gz cpu cpu load
Swift 2.38 32,908 2096 7.24 90% 58% 77% 80%
Java 2.14 36,192 2457 5.68 71% 58% 62% 77%
n-body
source secs mem gz cpu cpu load
Swift 24.86 4,496 1253 24.85 0% 100% 1% 0%
Java 21.50 27,240 1489 21.52 1% 1% 100% 0%
k-nucleotide
source secs mem gz cpu cpu load
Swift 20.55 219,908 1366 75.83 95% 94% 90% 91%
Java 8.02 467,004 1802 25.57 76% 98% 73% 74%
regex-dna
source secs mem gz cpu cpu load
Swift 102.23 285,340 713 102.18 1% 67% 33% 0%
Java 4.26 667,416 1085 11.69 59% 69% 90% 59%
Swift Swift version 3.1-dev (LLVM 2475cd4a8a, Clang bbab01d581, Swift bf16b699c5)
swift-DEVELOPMENT-SNAPSHOT-2017-01-24-a-ubuntu16.04
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)