OCaml VS Zig 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.)

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 2436ms 37ms 49.1MB 2407ms 13ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 1.ml 4394ms 23ms 120.7MB 4350ms 23ms ocaml 4.14.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 197ms 0.4ms 7.2MB 183ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 1.ml 284ms 2.7ms 17.4MB 263ms 3ms ocaml 4.14.0

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 1224ms 8.4ms 0.8MB 2360ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 3-i.zig 1348ms 0.9ms 0.6MB 1337ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 2.zig 2332ms 1.5ms 0.6MB 2320ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 1.zig 3027ms 6.5ms 0.6MB 3017ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 2.ml 3576ms 2.8ms 2.6MB 3560ms 0ms ocaml 4.14.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 3-i.zig 115ms 0.9ms 0.6MB 103ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 2-m.zig 119ms 3.5ms 0.7MB 200ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 2.zig 200ms 0.5ms 0.6MB 190ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 1.zig 253ms 0.5ms 0.6MB 240ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 2.ml 299ms 0.6ms 2.5MB 290ms 0ms ocaml 4.14.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 137ms 0.7ms 0.6MB 130ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 6.ml 387ms 0.8ms 24.5MB 370ms 0ms ocaml 4.14.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 16ms 0.1ms 0.6MB 10ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 6.ml 47ms 3.7ms 5.7MB 33ms 0ms ocaml 4.14.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 2.2ms 0.7ms 2.9MB 0ms 0ms ocaml 4.14.0
zig 1.zig 2.3ms 0.7ms 0.6MB 0ms 0ms zig 0.10.0-dev.4198+5e0d8a435

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 50ms 1.2ms 2.9MB 40ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 1.ml 231ms 0.7ms 5.9MB 213ms 0ms ocaml 4.14.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 138ms 0.4ms 2.8MB 127ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 1.ml 679ms 0.5ms 5.8MB 667ms 0ms ocaml 4.14.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 25ms 3.4ms 1.5MB 10ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 1.ml 102ms 0.9ms 5.2MB 90ms 0ms ocaml 4.14.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 1129ms 2.8ms 41.1MB 1100ms 13ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 1.ml 1706ms 12ms 62.7MB 1653ms 33ms ocaml 4.14.0
ocaml 2.ml 2834ms 23ms 70.4MB 2790ms 27ms ocaml 4.14.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 204ms 2.4ms 18.7MB 180ms 3ms ocaml 4.14.0
zig 1.zig 229ms 0.8ms 11.3MB 213ms 3ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 2.ml 458ms 4.5ms 23.6MB 437ms 7ms ocaml 4.14.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 260ms 4.4ms 0.7MB 247ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 1.zig 381ms 2.3ms 0.7MB 370ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 1.ml 549ms 0.6ms 2.4MB 540ms 0ms ocaml 4.14.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 28ms 0.5ms 0.7MB 20ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 1.zig 41ms 0.3ms 0.7MB 30ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 1.ml 59ms 0.7ms 2.6MB 50ms 0ms ocaml 4.14.0

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 377ms 1.1ms 6.1MB 367ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 2.ml 2573ms 9.8ms 21.6MB 2553ms 3ms ocaml 4.14.0
ocaml 1.ml 3310ms 2.4ms 555.8MB 3143ms 147ms ocaml 4.14.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 79ms 0.6ms 2.5MB 70ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 2.ml 608ms 1.5ms 9.0MB 593ms 0ms ocaml 4.14.0
ocaml 1.ml 671ms 10ms 142.5MB 617ms 37ms ocaml 4.14.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 0.0MB 0ms 0ms ocaml 4.14.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 666ms 3.8ms 50.7MB 637ms 17ms ocaml 4.14.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 910ms 2.3ms 1.7MB 1743ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 2.zig 1724ms 0.6ms 1.7MB 1710ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 1.zig 3843ms 0.5ms 0.7MB 3830ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 2.ml timeout 0.0ms 0.0MB 0ms 0ms ocaml 4.14.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 248ms 13ms 0.8MB 430ms 3ms zig 0.10.0-dev.4198+5e0d8a435
zig 2.zig 434ms 0.2ms 0.7MB 427ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 1.zig 951ms 0.8ms 0.7MB 940ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 2.ml 1522ms 0.9ms 3.4MB 1510ms 0ms ocaml 4.14.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 68ms 2.4ms 0.8MB 103ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 2.zig 112ms 1.3ms 0.7MB 100ms 0ms zig 0.10.0-dev.4198+5e0d8a435
zig 1.zig 244ms 0.4ms 0.7MB 233ms 0ms zig 0.10.0-dev.4198+5e0d8a435
ocaml 2.ml 386ms 3.1ms 3.0MB 370ms 0ms ocaml 4.14.0