C VS Java benchmarks

Current benchmark data was generated on Wed Feb 08 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8171M 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.)

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 2.4ms 0.7ms 1.4MB 0ms 0ms clang 14.0.0
c 1.c 2.6ms 0.8ms 1.3MB 0ms 0ms gcc 12.2.0
c 1.c 3.4ms 2.1ms 1.0MB 0ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
java 1.java 92ms 4.3ms 65.3MB 88ms 14ms graal/jvm 17.0.6
java 1.java 93ms 5.9ms 42.0MB 84ms 14ms openjdk 19
java 1.java 96ms 8.2ms 39.1MB 92ms 16ms openjdk 20
java 1.java 158ms 14ms 41.4MB 84ms 82ms openjdk/zgc 19

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1-m.c 292ms 5.8ms 23.5MB 480ms 13ms gcc 12.2.0
c 1-m.c 581ms 11ms 20.5MB 977ms 23ms clang 14.0.0
java 3-m.java 1707ms 43ms 114.5MB 3113ms 50ms openjdk 20
java 3-m.java 1746ms 44ms 116.1MB 3173ms 53ms openjdk 19
java 3-m.java 1925ms 87ms 169.4MB 3510ms 77ms graal/jvm 17.0.6
java 3-m.java 2294ms 86ms 173.8MB 4033ms 183ms openjdk/zgc 19

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 43ms 1.2ms 13.6MB 53ms 7ms gcc 12.2.0
c 1-m.c 71ms 3.2ms 9.7MB 113ms 0ms clang 14.0.0
java 3-m.java 522ms 16ms 87.2MB 857ms 53ms openjdk 20
java 3-m.java 535ms 20ms 89.6MB 880ms 50ms openjdk 19
java 3-m.java 574ms 23ms 95.3MB 840ms 113ms openjdk/zgc 19
java 3-m.java 779ms 189ms 196.9MB 1327ms 83ms graal/jvm 17.0.6

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 331ms 4.8ms 1.2MB 320ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 8-i.c 398ms 5.5ms 1.3MB 387ms 0ms gcc 12.2.0
c 5.c 403ms 1.6ms 1.3MB 390ms 0ms gcc 12.2.0
c 5.c 422ms 5.1ms 1.4MB 410ms 0ms clang 14.0.0
c 8-i.c 423ms 7.5ms 1.4MB 410ms 0ms clang 14.0.0
c 5.c 426ms 3.6ms 1.0MB 413ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 2.c 433ms 1.0ms 1.2MB 420ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 2.c 467ms 4.0ms 1.4MB 453ms 0ms clang 14.0.0
c 2.c 592ms 1.5ms 1.3MB 580ms 0ms gcc 12.2.0
java 1.java 688ms 13ms 89.8MB 730ms 17ms graal/jvm 17.0.6
java 1.java 755ms 7.1ms 40.4MB 757ms 27ms openjdk 20
java 1.java 764ms 8.1ms 43.4MB 763ms 23ms openjdk 19
java 1.java 846ms 17ms 44.4MB 793ms 80ms openjdk/zgc 19
java 2.java 2324ms 28ms 656.4MB 2277ms 213ms openjdk 20
java 2.java 2338ms 11ms 550.4MB 2307ms 183ms openjdk 19
java 2.java 3688ms 40ms 1609.1MB 2637ms 1277ms openjdk/zgc 19

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 37ms 1.3ms 1.3MB 27ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 8-i.c 43ms 1.7ms 1.3MB 30ms 0ms gcc 12.2.0
c 5.c 43ms 0.8ms 1.3MB 30ms 0ms gcc 12.2.0
c 5.c 45ms 1.0ms 1.4MB 37ms 0ms clang 14.0.0
c 8-i.c 45ms 0.2ms 1.4MB 30ms 0ms clang 14.0.0
c 2.c 47ms 0.6ms 1.2MB 40ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 2.c 51ms 2.5ms 1.4MB 40ms 0ms clang 14.0.0
c 5.c 53ms 4.0ms 1.0MB 43ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 2.c 63ms 0.8ms 1.3MB 50ms 0ms gcc 12.2.0
java 1.java 180ms 4.4ms 89.8MB 207ms 33ms graal/jvm 17.0.6
java 1.java 184ms 8.6ms 40.5MB 193ms 17ms openjdk 20
java 1.java 188ms 4.0ms 43.6MB 197ms 17ms openjdk 19
java 1.java 247ms 5.2ms 42.4MB 193ms 83ms openjdk/zgc 19
java 2.java 511ms 7.9ms 354.7MB 550ms 113ms openjdk 20
java 2.java 520ms 20ms 355.3MB 567ms 123ms openjdk 19
java 2.java 890ms 59ms 506.8MB 663ms 393ms openjdk/zgc 19

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 1081ms 39ms 40.2MB 1043ms 23ms zigcc 0.11.0-dev.1580+a5b34a61a
c 1.c 1125ms 33ms 41.0MB 1087ms 17ms gcc 12.2.0
c 1.c 1130ms 22ms 40.9MB 1090ms 27ms clang 14.0.0
java 2.java 1197ms 8.4ms 50.4MB 1237ms 20ms openjdk 20
java 1.java 1211ms 11ms 84.4MB 1233ms 30ms openjdk 19
java 1.java 1227ms 46ms 84.6MB 1247ms 40ms openjdk 20
java 2.java 1260ms 8.6ms 53.6MB 1313ms 13ms openjdk 19
java 2.java 1326ms 4.8ms 52.5MB 1300ms 87ms openjdk/zgc 19
java 1.java 1425ms 29ms 110.6MB 1363ms 120ms openjdk/zgc 19
java 1.java 1684ms 26ms 239.6MB 2347ms 127ms graal/jvm 17.0.6
java 2-m.java 2194ms 21ms 206.3MB 3857ms 123ms graal/jvm 17.0.6

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 128ms 0.8ms 11.0MB 117ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 1.c 143ms 6.8ms 11.7MB 127ms 0ms clang 14.0.0
c 1.c 146ms 0.9ms 11.7MB 130ms 0ms gcc 12.2.0
java 1.java 277ms 2.7ms 58.4MB 297ms 27ms openjdk 20
java 1.java 285ms 2.3ms 59.6MB 293ms 37ms openjdk 19
java 1.java 363ms 18ms 60.8MB 327ms 97ms openjdk/zgc 19
java 2.java 378ms 7.9ms 45.1MB 420ms 13ms openjdk 20
java 2.java 401ms 11ms 50.0MB 427ms 23ms openjdk 19
java 1.java 401ms 13ms 121.8MB 540ms 60ms graal/jvm 17.0.6
java 2.java 465ms 9.2ms 44.2MB 430ms 87ms openjdk/zgc 19
java 2-m.java 786ms 5.5ms 148.8MB 1357ms 80ms graal/jvm 17.0.6

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 1534ms 9.7ms 1.3MB 2990ms 3ms gcc 12.2.0
c 6-im.c 1961ms 20ms 1.3MB 3820ms 0ms gcc 12.2.0
c 4-m.c 1986ms 14ms 5.2MB 3877ms 0ms clang 14.0.0
c 6-im.c 1990ms 12ms 3.2MB 3890ms 7ms clang 14.0.0
c 5-im.c 1998ms 19ms 1.3MB 3857ms 0ms gcc 12.2.0
c 3-m.c 2263ms 5.2ms 3.2MB 4437ms 0ms clang 14.0.0
c 3-m.c 2269ms 18ms 1.3MB 4430ms 0ms gcc 12.2.0
c 5-im.c 2451ms 11ms 3.3MB 4797ms 0ms clang 14.0.0
java 2.java timeout 0.0ms 91.1MB 9620ms 57ms graal/jvm 17.0.6
java 2.java timeout 0.0ms 44.6MB 9673ms 23ms openjdk 19
java 2.java timeout 0.0ms 40.7MB 9670ms 23ms openjdk 20
java 2.java timeout 0.0ms 44.1MB 9580ms 63ms openjdk/zgc 19

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 397ms 1.4ms 1.3MB 750ms 0ms gcc 12.2.0
c 6-im.c 469ms 3.9ms 1.3MB 893ms 0ms gcc 12.2.0
c 6-im.c 499ms 7.3ms 3.3MB 957ms 0ms clang 14.0.0
c 4-m.c 505ms 1.7ms 3.1MB 963ms 0ms clang 14.0.0
c 5-im.c 516ms 3.1ms 1.3MB 970ms 3ms gcc 12.2.0
c 3-m.c 581ms 4.7ms 1.3MB 1117ms 0ms gcc 12.2.0
c 3-m.c 588ms 9.4ms 3.1MB 1127ms 0ms clang 14.0.0
c 5-im.c 629ms 5.3ms 3.2MB 1200ms 3ms clang 14.0.0
java 2-m.java 1423ms 72ms 91.9MB 2637ms 30ms graal/jvm 17.0.6
java 2-m.java 2021ms 51ms 41.9MB 3780ms 30ms openjdk 19
java 2-m.java 2159ms 141ms 43.9MB 3967ms 80ms openjdk/zgc 19
java 2-m.java 2484ms 111ms 40.8MB 4717ms 20ms openjdk 20

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 111ms 3.3ms 1.3MB 193ms 0ms gcc 12.2.0
c 6-im.c 127ms 1.0ms 1.3MB 223ms 0ms gcc 12.2.0
c 4-m.c 136ms 1.4ms 3.3MB 240ms 0ms clang 14.0.0
c 6-im.c 138ms 0.8ms 3.2MB 250ms 0ms clang 14.0.0
c 5-im.c 140ms 2.7ms 1.3MB 250ms 0ms gcc 12.2.0
c 3-m.c 158ms 1.8ms 3.5MB 283ms 0ms clang 14.0.0
c 3-m.c 162ms 8.8ms 1.3MB 287ms 0ms gcc 12.2.0
c 5-im.c 173ms 6.0ms 3.3MB 300ms 3ms clang 14.0.0
java 2-m.java 505ms 14ms 93.3MB 827ms 33ms graal/jvm 17.0.6
java 2-m.java 685ms 36ms 43.9MB 1207ms 23ms openjdk 19
java 2-m.java 719ms 39ms 42.2MB 1160ms 83ms openjdk/zgc 19
java 2-m.java 801ms 105ms 41.1MB 1323ms 20ms openjdk 20