C VS Java benchmarks

Current benchmark data was generated on Thu Sep 22 2022, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz (Model 106)

* -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.1ms 0.3ms 1.0MB 0ms 0ms gcc 12.2.0
c 1.c 3.1ms 1.7ms 0.6MB 0ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 1.c 3.1ms 1.3ms 1.1MB 0ms 0ms clang 11.0.0
java 1.java 70ms 3.1ms 63.4MB 70ms 10ms graal/jvm 17.0.4
java 1.java 78ms 5.0ms 42.7MB 78ms 6ms openjdk 20
java 1.java 82ms 3.6ms 40.8MB 78ms 8ms openjdk 19
java 1.java 119ms 4.8ms 39.9MB 78ms 52ms 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 255ms 11ms 23.5MB 407ms 13ms gcc 12.2.0
c 1-m.c 522ms 38ms 20.3MB 827ms 13ms clang 11.0.0
java 3-m.java 1454ms 18ms 114.9MB 2660ms 40ms openjdk 20
java 3-m.java 1468ms 27ms 117.1MB 2693ms 47ms openjdk 19
java 3-m.java 1599ms 70ms 191.0MB 2963ms 53ms graal/jvm 17.0.4
java 3-m.java 1935ms 42ms 175.5MB 3417ms 150ms openjdk/zgc 19

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 34ms 0.8ms 12.7MB 40ms 0ms gcc 12.2.0
c 1.c 64ms 5.5ms 9.7MB 90ms 5ms clang 11.0.0
java 3-m.java 459ms 22ms 93.2MB 763ms 27ms openjdk 20
java 3-m.java 475ms 7.0ms 94.5MB 717ms 80ms openjdk/zgc 19
java 3-m.java 487ms 66ms 96.8MB 830ms 23ms openjdk 19
java 3-m.java 679ms 63ms 161.5MB 1190ms 40ms graal/jvm 17.0.4

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 308ms 0.1ms 0.5MB 300ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 5.c 321ms 0.7ms 1.0MB 310ms 0ms gcc 12.2.0
c 5.c 329ms 0.5ms 0.6MB 320ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 2.c 338ms 0.3ms 0.6MB 330ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 8-i.c 346ms 3.0ms 1.1MB 333ms 0ms clang 11.0.0
c 5.c 367ms 0.2ms 1.1MB 357ms 0ms clang 11.0.0
c 8-i.c 367ms 3.6ms 1.0MB 353ms 0ms gcc 12.2.0
c 2.c 415ms 7.0ms 1.0MB 397ms 0ms clang 11.0.0
java 1.java 539ms 2.8ms 86.1MB 583ms 20ms graal/jvm 17.0.4
java 1.java 558ms 2.9ms 44.4MB 563ms 23ms openjdk 20
java 1.java 558ms 2.6ms 42.4MB 577ms 13ms openjdk 19
java 1.java 614ms 4.4ms 42.3MB 590ms 57ms openjdk/zgc 19
c 2.c 624ms 0.5ms 1.0MB 610ms 0ms gcc 12.2.0
java 2.java 1887ms 33ms 538.3MB 1923ms 107ms openjdk 19
java 2.java 1923ms 9.6ms 563.7MB 1950ms 127ms openjdk 20
java 2.java 2582ms 4.7ms 1219.4MB 2027ms 753ms openjdk/zgc 19

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 33ms 0.4ms 0.6MB 27ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 5.c 35ms 1.3ms 1.0MB 23ms 0ms gcc 12.2.0
c 5.c 36ms 0.3ms 0.6MB 27ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 2.c 36ms 0.1ms 0.6MB 30ms 0ms zigcc 0.10.0-dev.4060+61aaef0b0
c 8-i.c 39ms 0.4ms 1.0MB 30ms 0ms gcc 12.2.0
c 5.c 40ms 0.6ms 1.1MB 30ms 0ms clang 11.0.0
c 8-i.c 41ms 3.3ms 1.1MB 30ms 0ms clang 11.0.0
c 2.c 43ms 0.2ms 1.1MB 33ms 0ms clang 11.0.0
c 2.c 65ms 0.8ms 1.0MB 53ms 0ms gcc 12.2.0
java 1.java 142ms 3.9ms 42.7MB 157ms 17ms openjdk 20
java 1.java 144ms 1.6ms 86.4MB 190ms 20ms graal/jvm 17.0.4
java 1.java 146ms 5.8ms 42.7MB 167ms 10ms openjdk 19
java 1.java 190ms 3.5ms 42.2MB 160ms 57ms openjdk/zgc 19
java 2.java 414ms 4.9ms 363.3MB 493ms 70ms openjdk 20
java 2.java 417ms 2.1ms 355.0MB 483ms 73ms openjdk 19
java 2.java 676ms 0.7ms 455.4MB 547ms 290ms openjdk/zgc 19

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 781ms 22ms 88.1MB 807ms 23ms openjdk 20
c 1.c 796ms 36ms 40.1MB 757ms 17ms zigcc 0.10.0-dev.4060+61aaef0b0
c 1.c 812ms 22ms 41.0MB 780ms 10ms gcc 12.2.0
c 1.c 820ms 13ms 40.9MB 773ms 27ms clang 11.0.0
java 1.java 922ms 29ms 84.4MB 943ms 23ms openjdk 19
java 1.java 982ms 26ms 110.6MB 940ms 87ms openjdk/zgc 19
java 2.java 1003ms 4.6ms 52.7MB 1043ms 13ms openjdk 20
java 2.java 1028ms 5.3ms 52.2MB 1010ms 60ms openjdk/zgc 19
java 2.java 1039ms 37ms 54.3MB 1077ms 17ms openjdk 19
java 1-m.java 1472ms 70ms 163.9MB 2240ms 53ms graal/jvm 17.0.4
java 2-m.java 1848ms 24ms 128.2MB 3400ms 50ms graal/jvm 17.0.4

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 121ms 0.8ms 10.8MB 103ms 7ms zigcc 0.10.0-dev.4060+61aaef0b0
c 1.c 123ms 1.8ms 11.6MB 110ms 0ms clang 11.0.0
c 1.c 124ms 3.2ms 11.9MB 107ms 0ms gcc 12.2.0
java 1.java 236ms 2.7ms 62.5MB 270ms 13ms openjdk 20
java 1.java 237ms 4.6ms 62.3MB 257ms 27ms openjdk 19
java 1.java 280ms 5.4ms 60.9MB 263ms 60ms openjdk/zgc 19
java 2.java 325ms 6.4ms 48.8MB 363ms 10ms openjdk 20
java 2.java 326ms 0.8ms 48.2MB 360ms 17ms openjdk 19
java 1-m.java 332ms 8.9ms 135.3MB 470ms 43ms graal/jvm 17.0.4
java 2.java 360ms 3.3ms 44.2MB 353ms 50ms openjdk/zgc 19
java 2-m.java 611ms 3.6ms 127.9MB 1100ms 33ms graal/jvm 17.0.4

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 1397ms 12ms 1.0MB 2733ms 0ms gcc 12.2.0
c 6-im.c 1588ms 6.1ms 1.0MB 3110ms 0ms gcc 12.2.0
c 6-im.c 1722ms 4.5ms 3.0MB 3380ms 0ms clang 11.0.0
c 4-m.c 1749ms 11ms 2.9MB 3420ms 7ms clang 11.0.0
c 5-im.c 1847ms 1.6ms 1.0MB 3633ms 0ms gcc 12.2.0
c 5-im.c 2034ms 11ms 3.1MB 3990ms 0ms clang 11.0.0
c 3-m.c 2218ms 21ms 1.0MB 4350ms 0ms gcc 12.2.0
c 3-m.c 2222ms 12ms 3.2MB 4360ms 0ms clang 11.0.0
java 2-m.java 4306ms 8.2ms 104.9MB 8330ms 30ms graal/jvm 17.0.4
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 19
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk 20
java 2.java timeout 0.0ms 0.0MB 0ms 0ms openjdk/zgc 19

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 358ms 1.4ms 1.0MB 690ms 0ms gcc 12.2.0
c 6-im.c 406ms 1.9ms 1.0MB 780ms 0ms gcc 12.2.0
c 6-im.c 443ms 5.0ms 3.0MB 843ms 0ms clang 11.0.0
c 4-m.c 445ms 2.0ms 3.0MB 853ms 0ms clang 11.0.0
c 5-im.c 473ms 2.7ms 1.0MB 910ms 0ms gcc 12.2.0
c 5-im.c 522ms 9.3ms 3.1MB 1003ms 0ms clang 11.0.0
c 3-m.c 559ms 0.8ms 1.0MB 1087ms 0ms gcc 12.2.0
c 3-m.c 576ms 18ms 3.2MB 1100ms 0ms clang 11.0.0
java 2-m.java 1270ms 5.6ms 108.9MB 2323ms 37ms graal/jvm 17.0.4
java 2-m.java 1647ms 83ms 44.4MB 3100ms 20ms openjdk 19
java 2-m.java 1733ms 180ms 44.2MB 3290ms 17ms openjdk 20
java 2-m.java 1755ms 197ms 42.6MB 3250ms 57ms openjdk/zgc 19

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 97ms 0.9ms 1.0MB 170ms 0ms gcc 12.2.0
c 6-im.c 110ms 0.9ms 0.9MB 200ms 0ms gcc 12.2.0
c 6-im.c 118ms 0.6ms 3.1MB 210ms 0ms clang 11.0.0
c 4-m.c 121ms 3.1ms 3.1MB 213ms 0ms clang 11.0.0
c 5-im.c 128ms 2.7ms 1.0MB 233ms 0ms gcc 12.2.0
c 5-im.c 139ms 2.4ms 3.1MB 250ms 0ms clang 11.0.0
c 3-m.c 149ms 0.8ms 1.0MB 277ms 0ms gcc 12.2.0
c 3-m.c 153ms 2.3ms 3.2MB 273ms 0ms clang 11.0.0
java 2-m.java 446ms 11ms 98.3MB 743ms 40ms graal/jvm 17.0.4
java 2-m.java 563ms 42ms 44.2MB 1017ms 10ms openjdk 20
java 2-m.java 582ms 12ms 44.6MB 1037ms 17ms openjdk 19
java 2-m.java 647ms 16ms 44.4MB 1083ms 50ms openjdk/zgc 19