OCaml VS C benchmarks

Current benchmark data was generated on Thu May 04 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.)

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml timeout 0.0ms 145.4MB 4903ms 73ms ocaml 5.0.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 359ms 8.8ms 22.9MB 337ms 7ms ocaml 5.0.0

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 3637ms 2.2ms 2.7MB 3620ms 0ms ocaml 5.0.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 303ms 0.9ms 2.8MB 290ms 0ms ocaml 5.0.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 6.ml 387ms 4.7ms 22.7MB 360ms 7ms ocaml 5.0.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 6.ml 42ms 0.4ms 4.9MB 30ms 0ms ocaml 5.0.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 1.7ms 0.7ms 1.3MB 0ms 0ms gcc 13.1.0
c 1.c 1.8ms 0.5ms 1.4MB 0ms 0ms clang 14.0.0
c 1.c 2.2ms 0.4ms 1.0MB 0ms 0ms zigcc 0.11.0-dev.2969+855493bb8
ocaml 1.ml 2.9ms 0.5ms 2.7MB 0ms 0ms ocaml 5.0.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 250ms 4.9ms 6.7MB 240ms 0ms ocaml 5.0.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 727ms 1.6ms 6.7MB 717ms 0ms ocaml 5.0.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 110ms 0.4ms 6.0MB 93ms 0ms ocaml 5.0.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 1931ms 14ms 69.1MB 1880ms 30ms ocaml 5.0.0
ocaml 2.ml 3617ms 28ms 74.2MB 3557ms 43ms ocaml 5.0.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 275ms 3.8ms 25.6MB 253ms 3ms ocaml 5.0.0
ocaml 2.ml 629ms 19ms 30.1MB 610ms 7ms ocaml 5.0.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 295ms 0.8ms 1.3MB 287ms 0ms gcc 13.1.0
c 8-i.c 308ms 0.9ms 1.0MB 300ms 0ms zigcc 0.11.0-dev.2969+855493bb8
c 5.c 323ms 1.2ms 1.0MB 313ms 0ms zigcc 0.11.0-dev.2969+855493bb8
c 2.c 329ms 1.6ms 1.3MB 317ms 0ms gcc 13.1.0
c 5.c 334ms 0.5ms 1.2MB 323ms 0ms gcc 13.1.0
c 2.c 344ms 0.4ms 1.0MB 333ms 0ms zigcc 0.11.0-dev.2969+855493bb8
c 5.c 355ms 0.8ms 1.4MB 340ms 0ms clang 14.0.0
c 8-i.c 369ms 17ms 1.4MB 360ms 0ms clang 14.0.0
c 2.c 387ms 0.3ms 1.4MB 380ms 0ms clang 14.0.0
ocaml 1.ml 546ms 8.2ms 2.9MB 533ms 0ms ocaml 5.0.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 32ms 0.5ms 1.3MB 20ms 0ms gcc 13.1.0
c 5.c 35ms 0.9ms 0.9MB 27ms 0ms zigcc 0.11.0-dev.2969+855493bb8
c 8-i.c 35ms 3.5ms 1.0MB 27ms 0ms zigcc 0.11.0-dev.2969+855493bb8
c 5.c 36ms 0.3ms 1.3MB 27ms 0ms gcc 13.1.0
c 2.c 36ms 0.2ms 0.9MB 30ms 0ms zigcc 0.11.0-dev.2969+855493bb8
c 2.c 37ms 3.1ms 1.3MB 30ms 0ms gcc 13.1.0
c 5.c 38ms 0.6ms 1.4MB 30ms 0ms clang 14.0.0
c 8-i.c 40ms 2.8ms 1.4MB 30ms 0ms clang 14.0.0
c 2.c 42ms 1.2ms 1.4MB 30ms 0ms clang 14.0.0
ocaml 1.ml 59ms 0.7ms 2.8MB 50ms 0ms ocaml 5.0.0

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 1049ms 42ms 40.9MB 1013ms 13ms gcc 13.1.0
c 1.c 1063ms 25ms 40.1MB 1030ms 13ms zigcc 0.11.0-dev.2969+855493bb8
c 1.c 1105ms 55ms 40.9MB 1070ms 13ms clang 14.0.0
ocaml 2.ml 2718ms 31ms 19.1MB 2703ms 0ms ocaml 5.0.0
ocaml 1.ml 3571ms 30ms 550.6MB 3400ms 157ms ocaml 5.0.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 119ms 6.2ms 11.7MB 103ms 0ms gcc 13.1.0
c 1.c 121ms 4.5ms 11.6MB 107ms 0ms clang 14.0.0
c 1.c 123ms 1.3ms 11.1MB 110ms 0ms zigcc 0.11.0-dev.2969+855493bb8
ocaml 2.ml 640ms 4.4ms 9.3MB 627ms 0ms ocaml 5.0.0
ocaml 1.ml 763ms 24ms 140.2MB 713ms 30ms ocaml 5.0.0

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml timeout 0.0ms 181.9MB 4887ms 90ms ocaml 5.0.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 715ms 2.6ms 52.5MB 673ms 27ms ocaml 5.0.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 1285ms 17ms 1.3MB 2483ms 0ms gcc 13.1.0
c 5-im.c 1596ms 1.4ms 1.3MB 3123ms 0ms gcc 13.1.0
c 4-m.c 1635ms 2.9ms 3.2MB 3207ms 0ms clang 14.0.0
c 6-im.c 1637ms 1.7ms 1.3MB 3187ms 0ms gcc 13.1.0
c 6-im.c 1653ms 12ms 3.2MB 3227ms 0ms clang 14.0.0
c 3-m.c 1870ms 3.4ms 1.3MB 3667ms 0ms gcc 13.1.0
c 3-m.c 1874ms 16ms 3.3MB 3673ms 0ms clang 14.0.0
c 5-im.c 2035ms 24ms 5.2MB 3980ms 0ms clang 14.0.0
ocaml 2.ml timeout 0.0ms 4.2MB 4987ms 0ms ocaml 5.0.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 336ms 4.1ms 3.2MB 630ms 0ms gcc 13.1.0
c 5-im.c 411ms 1.0ms 1.3MB 780ms 0ms gcc 13.1.0
c 4-m.c 421ms 2.7ms 3.1MB 800ms 0ms clang 14.0.0
c 6-im.c 424ms 2.3ms 3.2MB 803ms 3ms clang 14.0.0
c 6-im.c 424ms 3.5ms 1.3MB 807ms 0ms gcc 13.1.0
c 3-m.c 473ms 0.8ms 3.2MB 910ms 0ms clang 14.0.0
c 3-m.c 477ms 1.1ms 1.3MB 910ms 0ms gcc 13.1.0
c 5-im.c 514ms 1.2ms 3.2MB 990ms 0ms clang 14.0.0
ocaml 2.ml 1540ms 14ms 3.5MB 1527ms 0ms ocaml 5.0.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 95ms 6.1ms 1.3MB 160ms 0ms gcc 13.1.0
c 5-im.c 112ms 1.0ms 1.3MB 200ms 0ms gcc 13.1.0
c 6-im.c 113ms 0.4ms 3.2MB 200ms 0ms clang 14.0.0
c 6-im.c 114ms 1.0ms 1.3MB 200ms 0ms gcc 13.1.0
c 4-m.c 116ms 4.5ms 3.6MB 200ms 0ms clang 14.0.0
c 3-m.c 129ms 0.9ms 1.3MB 230ms 0ms gcc 13.1.0
c 3-m.c 140ms 16ms 3.1MB 240ms 0ms clang 14.0.0
c 5-im.c 140ms 2.7ms 3.2MB 247ms 0ms clang 14.0.0
ocaml 2.ml 394ms 0.4ms 3.3MB 380ms 0ms ocaml 5.0.0