C VS Java benchmarks

Current benchmark data was generated on Sun Dec 01 2024, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][4 cores] AMD EPYC 7763 64-Core Processor (Model 1)

* -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 1.0ms 0.0ms 1.4MB 0ms 0ms zigcc 0.13.0
c 1.c 1.3ms 0.1ms 2.1MB 0ms 0ms gcc 14.2.0
c 1.c 1.3ms 0.1ms 2.1MB 0ms 0ms clang 14.0.0-1ubuntu1.1
java 1.java 68ms 3.0ms 59.0MB 70ms 20ms graal/jvm 17.0.8
java 1.java 73ms 4.6ms 44.8MB 74ms 22ms openjdk 23
java 1.java 77ms 1.6ms 43.8MB 76ms 20ms openjdk 21
java 1.java 187ms 4.1ms 44.6MB 82ms 128ms openjdk/zgc 21

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1-m.c 180ms 7.8ms 25.8MB 427ms 0ms gcc 14.2.0
c 1-m.c 298ms 4.2ms 27.7MB 1027ms 17ms clang 14.0.0-1ubuntu1.1
java 3-m.java 992ms 16ms 155.1MB 3317ms 67ms openjdk 23
java 3-m.java 1000ms 78ms 127.5MB 3403ms 30ms openjdk 21
java 3-m.java 1150ms 14ms 183.6MB 3873ms 70ms graal/jvm 17.0.8
java 3-m.java 1444ms 61ms 180.9MB 4577ms 197ms openjdk/zgc 21

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1-m.c 30ms 1.4ms 12.6MB 63ms 3ms gcc 14.2.0
c 1-m.c 38ms 0.4ms 14.9MB 100ms 3ms clang 14.0.0-1ubuntu1.1
java 3-m.java 332ms 16ms 101.3MB 963ms 43ms openjdk 21
java 3-m.java 345ms 27ms 89.8MB 977ms 67ms openjdk 23
java 3-m.java 361ms 32ms 141.0MB 980ms 53ms graal/jvm 17.0.8
java 3-m.java 440ms 3.1ms 98.5MB 930ms 167ms openjdk/zgc 21

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 245ms 1.0ms 1.5MB 230ms 0ms zigcc 0.13.0
c 5.c 298ms 0.2ms 1.5MB 283ms 0ms zigcc 0.13.0
c 8-i.c 301ms 1.8ms 2.1MB 290ms 0ms clang 14.0.0-1ubuntu1.1
c 2.c 308ms 1.0ms 2.3MB 300ms 0ms gcc 14.2.0
c 2.c 312ms 1.5ms 1.5MB 300ms 0ms zigcc 0.13.0
c 5.c 312ms 0.9ms 2.3MB 300ms 0ms gcc 14.2.0
c 5.c 315ms 2.3ms 2.1MB 307ms 0ms clang 14.0.0-1ubuntu1.1
c 2.c 317ms 2.8ms 2.1MB 307ms 0ms clang 14.0.0-1ubuntu1.1
c 8-i.c 332ms 0.1ms 2.3MB 320ms 0ms gcc 14.2.0
java 1.java 443ms 2.2ms 45.3MB 480ms 13ms openjdk 21
java 1.java 448ms 1.5ms 48.5MB 483ms 20ms openjdk 23
java 1.java 450ms 4.6ms 83.3MB 477ms 30ms graal/jvm 17.0.8
java 1.java 569ms 1.3ms 46.9MB 493ms 137ms openjdk/zgc 21
java 2.java 1248ms 2.9ms 611.8MB 1370ms 97ms openjdk 21
java 2.java 1255ms 4.8ms 780.5MB 1383ms 97ms openjdk 23
java 2.java 3283ms 56ms 2413.4MB 1647ms 1847ms openjdk/zgc 21

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 27ms 0.1ms 1.5MB 20ms 0ms zigcc 0.13.0
c 5.c 32ms 0.2ms 1.5MB 20ms 0ms zigcc 0.13.0
c 8-i.c 32ms 0.3ms 2.1MB 20ms 0ms clang 14.0.0-1ubuntu1.1
c 2.c 33ms 0.1ms 2.3MB 23ms 0ms gcc 14.2.0
c 5.c 34ms 0.6ms 2.3MB 20ms 0ms gcc 14.2.0
c 2.c 34ms 0.6ms 1.5MB 23ms 0ms zigcc 0.13.0
c 5.c 34ms 0.9ms 2.1MB 23ms 0ms clang 14.0.0-1ubuntu1.1
c 8-i.c 36ms 0.4ms 2.3MB 30ms 0ms gcc 14.2.0
c 2.c 37ms 5.1ms 2.1MB 27ms 0ms clang 14.0.0-1ubuntu1.1
java 1.java 120ms 2.1ms 87.3MB 137ms 37ms graal/jvm 17.0.8
java 1.java 121ms 1.0ms 45.4MB 163ms 17ms openjdk 21
java 1.java 123ms 1.3ms 48.3MB 157ms 13ms openjdk 23
java 1.java 245ms 0.4ms 44.9MB 160ms 140ms openjdk/zgc 21
java 2-m.java 307ms 2.9ms 343.0MB 450ms 57ms openjdk 21
java 2-m.java 313ms 5.4ms 387.7MB 447ms 67ms openjdk 23
java 2.java 704ms 8.8ms 536.4MB 473ms 420ms openjdk/zgc 21

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 278ms 2.0ms 40.9MB 257ms 10ms gcc 14.2.0
c 1.c 287ms 8.8ms 40.9MB 267ms 7ms clang 14.0.0-1ubuntu1.1
c 1.c 310ms 10ms 40.3MB 297ms 3ms zigcc 0.13.0
java 1.java 420ms 1.7ms 118.1MB 460ms 20ms openjdk 23
java 1.java 432ms 8.9ms 115.2MB 487ms 20ms openjdk 21
java 1.java 604ms 2.3ms 112.6MB 513ms 163ms openjdk/zgc 21
java 1-m.java 703ms 85ms 239.9MB 1043ms 80ms graal/jvm 17.0.8
java 2.java 781ms 3.3ms 60.6MB 833ms 13ms openjdk 23
java 2.java 789ms 8.6ms 57.0MB 850ms 20ms openjdk 21
java 2.java 844ms 0.9ms 55.1MB 773ms 147ms openjdk/zgc 21
java 2-m.java 1312ms 74ms 240.5MB 2287ms 103ms graal/jvm 17.0.8

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 53ms 2.4ms 11.6MB 40ms 0ms gcc 14.2.0
c 1.c 57ms 3.4ms 11.5MB 43ms 0ms clang 14.0.0-1ubuntu1.1
c 1.c 61ms 3.5ms 11.0MB 47ms 0ms zigcc 0.13.0
java 1.java 158ms 0.5ms 68.0MB 200ms 23ms openjdk 23
java 1.java 164ms 12ms 64.9MB 210ms 27ms openjdk 21
java 1-m.java 247ms 12ms 144.7MB 343ms 60ms graal/jvm 17.0.8
java 2.java 260ms 4.2ms 50.2MB 320ms 23ms openjdk 21
java 2.java 264ms 2.9ms 50.4MB 313ms 23ms openjdk 23
java 1.java 288ms 1.8ms 61.6MB 210ms 147ms openjdk/zgc 21
java 2.java 368ms 4.5ms 49.4MB 317ms 130ms openjdk/zgc 21
java 2-m.java 474ms 5.2ms 194.3MB 823ms 70ms graal/jvm 17.0.8

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 6-im.c 956ms 1.0ms 4.1MB 3750ms 0ms gcc 14.2.0
c 4-m.c 966ms 0.5ms 4.0MB 3790ms 0ms gcc 14.2.0
c 6-im.c 1012ms 17ms 5.1MB 3937ms 7ms clang 14.0.0-1ubuntu1.1
c 5-im.c 1124ms 47ms 4.1MB 4327ms 3ms gcc 14.2.0
c 4-m.c 1139ms 14ms 5.3MB 4427ms 10ms clang 14.0.0-1ubuntu1.1
c 5-im.c 1334ms 8.3ms 5.2MB 5227ms 3ms clang 14.0.0-1ubuntu1.1
c 3-m.c 1835ms 6.5ms 7.2MB 7190ms 10ms clang 14.0.0-1ubuntu1.1
java 2-m.java 1952ms 6.8ms 47.7MB 7430ms 20ms openjdk 21
java 2-m.java 1972ms 7.8ms 48.4MB 7477ms 27ms openjdk 23
c 3-m.c 1981ms 16ms 4.1MB 7780ms 0ms gcc 14.2.0
java 2-m.java 2092ms 3.1ms 45.2MB 7480ms 157ms openjdk/zgc 21
java 2-m.java 2443ms 23ms 101.0MB 8710ms 50ms graal/jvm 17.0.8

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 6-im.c 251ms 2.9ms 4.0MB 953ms 0ms gcc 14.2.0
c 4-m.c 253ms 1.2ms 4.1MB 957ms 0ms gcc 14.2.0
c 6-im.c 261ms 3.2ms 7.2MB 973ms 0ms clang 14.0.0-1ubuntu1.1
c 5-im.c 290ms 11ms 4.0MB 1093ms 0ms gcc 14.2.0
c 4-m.c 291ms 2.9ms 5.4MB 1097ms 0ms clang 14.0.0-1ubuntu1.1
c 5-im.c 342ms 3.7ms 5.4MB 1313ms 0ms clang 14.0.0-1ubuntu1.1
c 3-m.c 479ms 25ms 7.3MB 1803ms 10ms clang 14.0.0-1ubuntu1.1
c 3-m.c 502ms 2.4ms 4.0MB 1950ms 0ms gcc 14.2.0
java 2-m.java 595ms 4.1ms 49.1MB 2077ms 30ms openjdk 23
java 2-m.java 595ms 6.5ms 47.6MB 2087ms 20ms openjdk 21
java 2-m.java 718ms 4.6ms 47.3MB 2043ms 143ms openjdk/zgc 21
java 2-m.java 738ms 17ms 99.2MB 2487ms 33ms graal/jvm 17.0.8

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 6-im.c 72ms 0.5ms 7.0MB 243ms 0ms clang 14.0.0-1ubuntu1.1
c 4-m.c 74ms 3.3ms 4.1MB 257ms 0ms gcc 14.2.0
c 6-im.c 74ms 6.9ms 4.0MB 250ms 0ms gcc 14.2.0
c 5-im.c 80ms 1.3ms 4.0MB 283ms 0ms gcc 14.2.0
c 4-m.c 82ms 2.6ms 7.0MB 277ms 0ms clang 14.0.0-1ubuntu1.1
c 5-im.c 95ms 3.2ms 5.2MB 333ms 3ms clang 14.0.0-1ubuntu1.1
c 3-m.c 124ms 1.2ms 5.3MB 450ms 0ms clang 14.0.0-1ubuntu1.1
c 3-m.c 134ms 0.3ms 4.0MB 497ms 0ms gcc 14.2.0
java 2-m.java 238ms 1.1ms 47.6MB 670ms 33ms openjdk 21
java 2-m.java 246ms 2.6ms 48.9MB 710ms 23ms openjdk 23
java 2-m.java 277ms 22ms 96.4MB 793ms 27ms graal/jvm 17.0.8
java 2-m.java 370ms 2.2ms 47.2MB 717ms 143ms openjdk/zgc 21