Swift VS Java benchmarks

Current benchmark data was generated on Fri Sep 30 2022, 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 1418ms 8.8ms 91.7MB 2653ms 37ms graal/jvm 17.0.4
java 1-m.java 1579ms 40ms 42.2MB 2890ms 80ms openjdk/zgc 19
java 1-m.java 1582ms 75ms 42.1MB 3000ms 13ms openjdk 19
java 1-m.java 1585ms 94ms 44.3MB 3030ms 20ms openjdk 20
swift 1.swift 2936ms 31ms 5.3MB 2920ms 0ms swift 5.7.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 245ms 0.7ms 5.0MB 230ms 0ms swift 5.7.0
java 1-m.java 263ms 5.7ms 42.2MB 420ms 10ms openjdk 19
java 1-m.java 264ms 8.7ms 44.1MB 410ms 23ms openjdk 20
java 1-m.java 292ms 38ms 100.0MB 440ms 37ms graal/jvm 17.0.4
java 1-m.java 317ms 7.1ms 44.0MB 403ms 77ms openjdk/zgc 19

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3-m.swift 312ms 5.4ms 22.9MB 553ms 7ms swift 5.7.0
java 4.java 466ms 12ms 41.7MB 540ms 17ms openjdk 19
java 4.java 470ms 6.4ms 43.9MB 547ms 13ms openjdk 20
java 4.java 526ms 14ms 43.5MB 547ms 70ms openjdk/zgc 19
java 4-m.java 549ms 6.3ms 118.4MB 850ms 47ms graal/jvm 17.0.4

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 60ms 19ms 14.7MB 47ms 3ms swift 5.7.0
java 4.java 142ms 2.0ms 41.3MB 160ms 10ms openjdk 19
java 4.java 142ms 1.7ms 42.9MB 157ms 20ms openjdk 20
java 4.java 156ms 7.9ms 82.9MB 173ms 37ms graal/jvm 17.0.4
java 4.java 201ms 3.0ms 41.3MB 170ms 63ms openjdk/zgc 19

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2.2ms 0.8ms 2.4MB 0ms 0ms swift 5.7.0
java 1.java 77ms 2.0ms 58.0MB 70ms 14ms graal/jvm 17.0.4
java 1.java 83ms 3.5ms 40.6MB 80ms 10ms openjdk 20
java 1.java 89ms 4.9ms 40.5MB 78ms 10ms openjdk 19
java 1.java 136ms 2.5ms 39.9MB 80ms 68ms 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 1499ms 3.9ms 116.2MB 2733ms 37ms openjdk 19
java 3-m.java 1513ms 13ms 114.9MB 2747ms 47ms openjdk 20
java 3-m.java 1537ms 13ms 192.2MB 2767ms 93ms graal/jvm 17.0.4
java 3-m.java 2015ms 5.0ms 174.5MB 3473ms 177ms openjdk/zgc 19
swift 2-m.swift 2016ms 27ms 44.3MB 3780ms 23ms swift 5.7.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 339ms 1.6ms 33.3MB 573ms 13ms swift 5.7.0
java 3-m.java 429ms 5.9ms 92.9MB 690ms 33ms openjdk 20
java 3-m.java 503ms 8.8ms 94.1MB 727ms 100ms openjdk/zgc 19
java 3-m.java 508ms 64ms 96.7MB 820ms 50ms openjdk 19
java 3-m.java 739ms 144ms 179.8MB 1260ms 90ms graal/jvm 17.0.4

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 449ms 0.8ms 5.0MB 440ms 0ms swift 5.7.0
java 1.java 586ms 6.5ms 87.4MB 627ms 30ms graal/jvm 17.0.4
java 1.java 638ms 5.0ms 44.2MB 647ms 20ms openjdk 19
java 1.java 643ms 3.3ms 42.4MB 650ms 23ms openjdk 20
java 1.java 705ms 4.7ms 42.0MB 663ms 73ms openjdk/zgc 19
java 2.java 2299ms 9.1ms 534.4MB 2290ms 163ms openjdk 20
java 2.java 2309ms 29ms 487.1MB 2310ms 157ms openjdk 19
java 2.java 3386ms 50ms 1654.7MB 2387ms 1197ms openjdk/zgc 19

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 49ms 1.5ms 5.0MB 40ms 0ms swift 5.7.0
java 1.java 157ms 3.9ms 42.3MB 170ms 10ms openjdk 19
java 1.java 157ms 4.7ms 42.7MB 170ms 20ms openjdk 20
java 1.java 157ms 3.0ms 87.9MB 203ms 23ms graal/jvm 17.0.4
java 1.java 214ms 4.5ms 43.5MB 183ms 63ms openjdk/zgc 19
java 2.java 480ms 11ms 354.0MB 527ms 93ms openjdk 20
java 2.java 482ms 9.4ms 345.0MB 523ms 103ms openjdk 19
java 2.java 802ms 2.3ms 484.3MB 590ms 367ms 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 0.0MB 0ms 0ms graal/jvm 17.0.4
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 19
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 20
java 1.java timeout 0.0ms 0.0MB 0ms 0ms openjdk/zgc 19
swift 1.swift timeout 0.0ms 0.0MB 0ms 0ms swift 5.7.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 1515ms 17ms 317.7MB 1813ms 113ms openjdk 19
java 1.java 1529ms 15ms 309.2MB 1803ms 107ms openjdk 20
java 1.java 1564ms 6.5ms 384.4MB 1910ms 120ms graal/jvm 17.0.4
java 1.java 2102ms 48ms 967.5MB 1730ms 713ms openjdk/zgc 19
swift 1.swift 2755ms 11ms 6.7MB 2727ms 3ms swift 5.7.0