Swift VS Java benchmarks

Current benchmark data was generated on Mon Feb 06 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz (Model 85)

* -m in a file name stands for multi-threading or multi-processing

* -i in a file name stands for direct intrinsics usage. (Usage of simd intrinsics via libraries is not counted)

* -ffi in a file name stands for non-stdlib FFI usage

* (You may find time < time(user) + time(sys) for some non-parallelized programs, the overhead is from GC or JIT compiler, which are allowed to take advantage of multi-cores as that's more close to real-world scenarios.)

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1-m.java 1518ms 8.7ms 40.6MB 2877ms 20ms openjdk 20
java 1-m.java 1550ms 114ms 93.8MB 2910ms 37ms graal/jvm 17.0.6
java 1-m.java 1568ms 35ms 42.2MB 2860ms 77ms openjdk/zgc 19
java 1-m.java 1610ms 36ms 41.9MB 3050ms 13ms openjdk 19
swift 1.swift 2924ms 4.7ms 2.4MB 2910ms 0ms swift 5.7.3

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 245ms 1.3ms 2.4MB 230ms 0ms swift 5.7.3
java 1-m.java 256ms 4.9ms 40.6MB 410ms 3ms openjdk 20
java 1-m.java 266ms 5.7ms 41.8MB 410ms 17ms openjdk 19
java 1-m.java 285ms 24ms 90.2MB 443ms 30ms graal/jvm 17.0.6
java 1.java 324ms 9.0ms 42.0MB 420ms 63ms openjdk/zgc 19

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 405ms 28ms 22.7MB 537ms 10ms swift 5.7.3
java 4.java 472ms 15ms 40.5MB 540ms 20ms openjdk 20
java 4.java 477ms 7.5ms 43.4MB 550ms 10ms openjdk 19
java 4.java 536ms 5.5ms 41.8MB 547ms 73ms openjdk/zgc 19
java 4.java 555ms 7.5ms 97.9MB 757ms 33ms graal/jvm 17.0.6

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 65ms 1.8ms 14.7MB 40ms 7ms swift 5.7.3
java 4.java 151ms 4.9ms 40.7MB 160ms 13ms openjdk 19
java 4.java 152ms 14ms 39.8MB 170ms 13ms openjdk 20
java 4.java 159ms 10ms 86.3MB 180ms 30ms graal/jvm 17.0.6
java 4.java 210ms 11ms 41.2MB 170ms 70ms openjdk/zgc 19

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 3.4ms 0.1ms 0.0MB 0ms 0ms swift 5.7.3
java 1.java 80ms 2.1ms 48.1MB 72ms 14ms graal/jvm 17.0.6
java 1.java 87ms 9.2ms 39.3MB 78ms 16ms openjdk 20
java 1.java 93ms 4.7ms 42.4MB 76ms 24ms openjdk 19
java 1.java 150ms 9.1ms 41.0MB 86ms 64ms openjdk/zgc 19

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 3-m.java 1420ms 16ms 113.4MB 2567ms 40ms openjdk 20
java 3-m.java 1510ms 5.7ms 115.0MB 2733ms 40ms openjdk 19
java 3-m.java 1680ms 28ms 165.9MB 3040ms 73ms graal/jvm 17.0.6
java 3-m.java 2020ms 14ms 173.9MB 3490ms 163ms openjdk/zgc 19
swift 2-m.swift 2227ms 12ms 42.1MB 4180ms 30ms swift 5.7.3

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 393ms 32ms 33.6MB 630ms 17ms swift 5.7.3
java 3-m.java 427ms 3.1ms 88.2MB 693ms 47ms openjdk 20
java 3-m.java 515ms 8.3ms 94.0MB 723ms 117ms openjdk/zgc 19
java 3-m.java 517ms 69ms 94.1MB 863ms 37ms openjdk 19
java 3-m.java 534ms 30ms 136.2MB 877ms 63ms graal/jvm 17.0.6

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 453ms 6.5ms 5.2MB 443ms 0ms swift 5.7.3
java 1.java 599ms 11ms 89.9MB 623ms 27ms graal/jvm 17.0.6
java 1.java 651ms 5.4ms 40.6MB 660ms 10ms openjdk 20
java 1.java 661ms 11ms 42.0MB 657ms 23ms openjdk 19
java 1.java 707ms 18ms 41.7MB 650ms 70ms openjdk/zgc 19
java 2.java 2110ms 21ms 516.4MB 2083ms 167ms openjdk 20
java 2.java 2163ms 14ms 550.9MB 2123ms 173ms openjdk 19
java 2.java 2913ms 129ms 1417.8MB 2140ms 963ms openjdk/zgc 19

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 49ms 2.8ms 5.2MB 40ms 0ms swift 5.7.3
java 1.java 160ms 6.0ms 40.5MB 167ms 23ms openjdk 20
java 1.java 163ms 3.2ms 89.9MB 190ms 30ms graal/jvm 17.0.6
java 1.java 178ms 5.1ms 42.0MB 170ms 23ms openjdk 19
java 1.java 217ms 7.7ms 43.8MB 173ms 63ms openjdk/zgc 19
java 2.java 460ms 1.3ms 347.4MB 490ms 107ms openjdk 20
java 2.java 488ms 15ms 362.6MB 517ms 107ms openjdk 19
java 2.java 793ms 2.4ms 487.0MB 563ms 377ms openjdk/zgc 19

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java timeout 0.0ms 331.1MB 5447ms 97ms graal/jvm 17.0.6
java 1.java timeout 0.0ms 284.6MB 5387ms 110ms openjdk 19
java 1.java timeout 0.0ms 270.7MB 5410ms 100ms openjdk 20
java 1.java timeout 0.0ms 1375.1MB 4547ms 903ms openjdk/zgc 19
swift 1.swift timeout 0.0ms 6.7MB 4970ms 10ms swift 5.7.3

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 1451ms 18ms 261.6MB 1790ms 90ms openjdk 19
java 1.java 1458ms 14ms 295.9MB 1767ms 100ms openjdk 20
java 1.java 1543ms 16ms 342.7MB 1893ms 113ms graal/jvm 17.0.6
java 1.java 2059ms 27ms 987.0MB 1660ms 750ms openjdk/zgc 19
swift 1.swift 2616ms 0.1ms 6.3MB 2600ms 3ms swift 5.7.3