C++ VS Ocaml benchmarks

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

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1-im.cpp 679ms 11ms 1.0MB 1237ms 3ms g++ 12.1.0
cpp 1-im.cpp 688ms 11ms 3.6MB 1337ms 0ms clang++ 11.0.0
ocaml 2.ml 3161ms 11ms 2.6MB 3147ms 0ms ocaml 4.14.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1-im.cpp 67ms 5.0ms 3.6MB 110ms 0ms clang++ 11.0.0
cpp 1-im.cpp 69ms 1.8ms 1.0MB 100ms 0ms g++ 12.1.0
ocaml 2.ml 262ms 0.5ms 2.5MB 250ms 0ms ocaml 4.14.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1.cpp 1.8ms 0.7ms 1.0MB 0ms 0ms g++ 12.1.0
ocaml 1.ml 2.3ms 0.4ms 2.9MB 0ms 0ms ocaml 4.14.0
cpp 1.cpp 2.8ms 0.8ms 1.0MB 0ms 0ms clang++ 11.0.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 167ms 0.4ms 0.9MB 160ms 0ms g++ 12.1.0
cpp 0-i.cpp 212ms 0.4ms 1.1MB 200ms 0ms clang++ 11.0.0
cpp 1.cpp 307ms 5.8ms 0.9MB 293ms 0ms g++ 12.1.0
cpp 1.cpp 392ms 6.8ms 1.1MB 383ms 0ms clang++ 11.0.0
ocaml 1.ml 526ms 39ms 2.4MB 513ms 0ms ocaml 4.14.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 21ms 1.0ms 0.9MB 10ms 0ms g++ 12.1.0
cpp 0-i.cpp 24ms 1.9ms 1.1MB 13ms 0ms clang++ 11.0.0
cpp 1.cpp 33ms 0.1ms 0.9MB 20ms 0ms g++ 12.1.0
cpp 1.cpp 42ms 0.3ms 1.1MB 30ms 0ms clang++ 11.0.0
ocaml 1.ml 59ms 0.6ms 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
cpp 1.cpp 369ms 18ms 7.4MB 357ms 0ms clang++ 11.0.0
cpp 1.cpp 578ms 2.4ms 7.7MB 567ms 0ms g++ 12.1.0
ocaml 2.ml 2591ms 2.3ms 19.8MB 2577ms 3ms ocaml 4.14.0
ocaml 1.ml 3328ms 22ms 555.2MB 3160ms 150ms ocaml 4.14.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1.cpp 78ms 5.3ms 3.7MB 67ms 0ms clang++ 11.0.0
cpp 1.cpp 138ms 9.6ms 4.0MB 130ms 0ms g++ 12.1.0
ocaml 2.ml 612ms 2.4ms 8.9MB 593ms 0ms ocaml 4.14.0
ocaml 1.ml 678ms 11ms 142.5MB 630ms 30ms ocaml 4.14.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 7-m.cpp 885ms 14ms 3.2MB 1717ms 0ms clang++ 11.0.0
cpp 8-m.cpp 885ms 14ms 3.2MB 1723ms 0ms clang++ 11.0.0
cpp 7-m.cpp 886ms 13ms 1.0MB 1707ms 0ms g++ 12.1.0
cpp 8-m.cpp 905ms 2.6ms 0.9MB 1763ms 0ms g++ 12.1.0
cpp 6-im.cpp 1804ms 22ms 3.2MB 3530ms 10ms clang++ 11.0.0
cpp 6-im.cpp 1808ms 11ms 0.9MB 3423ms 7ms g++ 12.1.0
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
cpp 7-m.cpp 226ms 6.2ms 3.2MB 413ms 0ms clang++ 11.0.0
cpp 7-m.cpp 230ms 6.3ms 1.0MB 420ms 0ms g++ 12.1.0
cpp 8-m.cpp 232ms 6.2ms 3.1MB 433ms 0ms clang++ 11.0.0
cpp 8-m.cpp 236ms 1.3ms 1.0MB 440ms 0ms g++ 12.1.0
cpp 6-im.cpp 462ms 2.2ms 1.0MB 877ms 0ms g++ 12.1.0
cpp 6-im.cpp 470ms 2.8ms 3.2MB 897ms 0ms clang++ 11.0.0
ocaml 2.ml 1344ms 0.8ms 3.4MB 1330ms 0ms ocaml 4.14.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 7-m.cpp 63ms 1.6ms 3.1MB 103ms 0ms clang++ 11.0.0
cpp 7-m.cpp 63ms 1.3ms 0.9MB 103ms 0ms g++ 12.1.0
cpp 8-m.cpp 65ms 1.8ms 3.2MB 110ms 0ms clang++ 11.0.0
cpp 8-m.cpp 67ms 1.8ms 1.0MB 110ms 0ms g++ 12.1.0
cpp 6-im.cpp 123ms 2.8ms 0.9MB 220ms 0ms g++ 12.1.0
cpp 6-im.cpp 127ms 3.0ms 3.1MB 223ms 0ms clang++ 11.0.0
ocaml 2.ml 385ms 0.1ms 3.1MB 373ms 0ms ocaml 4.14.0