OCaml VS Kotlin benchmarks

Current benchmark data was generated on Wed Feb 08 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8171M 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
kotlin 1.kt 793ms 13ms 413.5MB 770ms 157ms kotlin/jvm 17.0.2
kotlin 1.kt timeout 0.0ms 194.4MB 8290ms 1107ms kotlin/native 1.8.10
ocaml 1.ml timeout 0.0ms 139.4MB 4927ms 50ms ocaml 5.0.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 155ms 4.2ms 109.3MB 123ms 43ms kotlin/jvm 17.0.2
ocaml 1.ml 395ms 6.2ms 22.9MB 363ms 13ms ocaml 5.0.0
kotlin 1-m.kt 657ms 26ms 34.4MB 1093ms 130ms kotlin/native 1.8.10

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 4303ms 54ms 2.8MB 4290ms 0ms ocaml 5.0.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 356ms 7.7ms 2.9MB 343ms 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 450ms 2.9ms 22.7MB 433ms 3ms ocaml 5.0.0

Input: 250000

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

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 2.6ms 0.4ms 1.5MB 0ms 0ms kotlin/native 1.8.10
ocaml 1.ml 2.6ms 0.9ms 2.9MB 0ms 0ms ocaml 5.0.0
kotlin 1.kt 78ms 1.3ms 40.7MB 62ms 10ms kotlin/jvm 17.0.2

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 290ms 2.9ms 6.7MB 277ms 0ms ocaml 5.0.0
kotlin 2-m.kt 300ms 6.2ms 113.5MB 417ms 47ms kotlin/jvm 17.0.2
kotlin 1.kt 303ms 5.8ms 109.7MB 373ms 30ms kotlin/jvm 17.0.2
kotlin 2-m.kt 531ms 3.3ms 42.3MB 777ms 33ms kotlin/native 1.8.10
kotlin 1.kt timeout 0.0ms 15.0MB 5003ms 7ms kotlin/native 1.8.10

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2.kt 497ms 17ms 130.5MB 600ms 57ms kotlin/jvm 17.0.2
kotlin 1.kt 592ms 9.7ms 132.2MB 643ms 43ms kotlin/jvm 17.0.2
ocaml 1.ml 860ms 8.8ms 6.8MB 847ms 0ms ocaml 5.0.0
kotlin 2-m.kt 1648ms 11ms 114.0MB 2420ms 93ms kotlin/native 1.8.10
kotlin 1.kt timeout 0.0ms 15.0MB 4997ms 10ms kotlin/native 1.8.10

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 130ms 0.3ms 5.9MB 120ms 0ms ocaml 5.0.0
kotlin 1.kt 220ms 4.7ms 77.2MB 297ms 30ms kotlin/jvm 17.0.2
kotlin 2-m.kt 221ms 14ms 78.5MB 307ms 40ms kotlin/jvm 17.0.2
kotlin 2-m.kt 264ms 5.1ms 32.3MB 410ms 20ms kotlin/native 1.8.10
kotlin 1.kt timeout 0.0ms 17.1MB 4997ms 13ms kotlin/native 1.8.10

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 580ms 1.6ms 363.2MB 553ms 110ms kotlin/jvm 17.0.2
ocaml 1.ml 2018ms 8.8ms 69.1MB 1967ms 33ms ocaml 5.0.0
kotlin 1-m.kt 3664ms 86ms 138.6MB 5797ms 787ms kotlin/native 1.8.10
ocaml 2.ml 3866ms 14ms 74.3MB 3803ms 47ms ocaml 5.0.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 234ms 5.3ms 221.4MB 200ms 63ms kotlin/jvm 17.0.2
ocaml 1.ml 296ms 3.1ms 25.8MB 263ms 10ms ocaml 5.0.0
ocaml 2.ml 685ms 5.7ms 30.2MB 653ms 13ms ocaml 5.0.0
kotlin 1-m.kt 732ms 13ms 38.4MB 1173ms 133ms kotlin/native 1.8.10

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 668ms 18ms 2.9MB 653ms 0ms ocaml 5.0.0
kotlin 1.kt 768ms 9.5ms 42.9MB 757ms 27ms kotlin/jvm 17.0.2
kotlin 1n.kt 837ms 45ms 1.5MB 827ms 0ms kotlin/native 1.8.10

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 74ms 3.1ms 2.9MB 63ms 0ms ocaml 5.0.0
kotlin 1n.kt 88ms 3.6ms 1.5MB 80ms 0ms kotlin/native 1.8.10
kotlin 1.kt 185ms 11ms 43.0MB 183ms 20ms kotlin/jvm 17.0.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 2737ms 6.5ms 550.4MB 2570ms 153ms ocaml 5.0.0
ocaml 2.ml 3263ms 200ms 19.0MB 3240ms 7ms ocaml 5.0.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 557ms 15ms 140.2MB 507ms 33ms ocaml 5.0.0
ocaml 2.ml 811ms 68ms 9.1MB 797ms 0ms ocaml 5.0.0

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt timeout 0.0ms 161.4MB 5357ms 67ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 277.3MB 5270ms 943ms kotlin/native 1.8.10
ocaml 2.ml timeout 0.0ms 125.5MB 4923ms 50ms ocaml 5.0.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 818ms 6.0ms 52.5MB 780ms 20ms ocaml 5.0.0
kotlin 1.kt 1213ms 13ms 96.9MB 1667ms 37ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 65.1MB 6333ms 47ms kotlin/native 1.8.10

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml timeout 0.0ms 4.0MB 4983ms 0ms ocaml 5.0.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 1802ms 7.5ms 3.6MB 1787ms 0ms ocaml 5.0.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 475ms 16ms 3.4MB 460ms 0ms ocaml 5.0.0