OCaml VS Go benchmarks

Current benchmark data was generated on Mon Jun 23 2025, 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.)

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 1752ms 19ms 51.9MB 1730ms 10ms tinygo 0.38.0
go 1-m.go 2372ms 7.5ms 42.0MB 5283ms 43ms go 1.24.4
ocaml 1.ml 3028ms 44ms 157.2MB 2940ms 73ms ocaml 5.3.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 154ms 0.3ms 5.0MB 140ms 0ms tinygo 0.38.0
go 1-m.go 209ms 2.0ms 7.9MB 373ms 7ms go 1.24.4
ocaml 1.ml 214ms 0.9ms 19.1MB 200ms 0ms ocaml 5.3.0

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 673ms 1.0ms 5.6MB 2600ms 0ms go 1.24.4
go 3-m.go 726ms 2.7ms 2.9MB 2673ms 37ms tinygo 0.38.0
ocaml 2.ml 2914ms 16ms 4.9MB 2907ms 0ms ocaml 5.3.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 74ms 0.2ms 5.5MB 197ms 0ms go 1.24.4
go 3-m.go 102ms 2.8ms 2.9MB 187ms 33ms tinygo 0.38.0
ocaml 2.ml 245ms 3.3ms 4.9MB 237ms 0ms ocaml 5.3.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 125ms 0.3ms 7.5MB 380ms 0ms go 1.24.4
ocaml 6.ml 347ms 1.7ms 24.8MB 337ms 0ms ocaml 5.3.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 17ms 0.6ms 7.6MB 30ms 0ms go 1.24.4
ocaml 6.ml 39ms 0.5ms 7.5MB 30ms 0ms ocaml 5.3.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 0.7ms 0.0ms 0.3MB 0ms 0ms tinygo 0.38.0
go 1.go 1.4ms 0.1ms 3.4MB 0ms 0ms go 1.24.4
ocaml 1.ml 1.8ms 0.2ms 5.0MB 0ms 0ms ocaml 5.3.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 121ms 1.2ms 3.5MB 113ms 0ms go 1.24.4
go 3.go 132ms 2.6ms 0.4MB 127ms 0ms tinygo 0.38.0
ocaml 1.ml 190ms 0.6ms 6.4MB 180ms 0ms ocaml 5.3.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 383ms 2.1ms 0.4MB 373ms 0ms tinygo 0.38.0
go 3.go 394ms 12ms 3.5MB 387ms 0ms go 1.24.4
ocaml 1.ml 518ms 3.2ms 6.6MB 510ms 0ms ocaml 5.3.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 51ms 1.2ms 3.5MB 40ms 0ms go 1.24.4
go 3.go 67ms 2.9ms 0.3MB 60ms 0ms tinygo 0.38.0
ocaml 1.ml 77ms 1.4ms 5.9MB 70ms 0ms ocaml 5.3.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 1049ms 0.9ms 35.4MB 1030ms 0ms tinygo 0.38.0
ocaml 1.ml 1094ms 11ms 70.2MB 1047ms 30ms ocaml 5.3.0
go 2.go 1343ms 6.2ms 51.9MB 1317ms 10ms tinygo 0.38.0
go 1-m.go 1463ms 6.3ms 38.9MB 3117ms 33ms go 1.24.4
go 2-m.go 1677ms 22ms 40.9MB 3687ms 33ms go 1.24.4
ocaml 2.ml 2066ms 16ms 91.8MB 2013ms 33ms ocaml 5.3.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 147ms 4.1ms 21.7MB 130ms 7ms ocaml 5.3.0
go 1.go 211ms 4.8ms 11.6MB 197ms 0ms tinygo 0.38.0
go 2.go 258ms 3.7ms 15.4MB 247ms 0ms tinygo 0.38.0
go 1-m.go 340ms 9.7ms 12.1MB 670ms 23ms go 1.24.4
ocaml 2.ml 367ms 7.6ms 27.7MB 343ms 7ms ocaml 5.3.0
go 2-m.go 372ms 0.6ms 14.0MB 787ms 20ms go 1.24.4

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 346ms 1.4ms 0.3MB 337ms 0ms tinygo 0.38.0
go 1.go 349ms 1.6ms 3.5MB 340ms 0ms go 1.24.4
ocaml 1.ml 373ms 1.9ms 5.2MB 360ms 0ms ocaml 5.3.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 36ms 0.4ms 0.3MB 30ms 0ms tinygo 0.38.0
go 1.go 37ms 0.1ms 3.5MB 30ms 0ms go 1.24.4
ocaml 1.ml 41ms 1.4ms 5.2MB 30ms 0ms ocaml 5.3.0

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 300ms 4.8ms 71.7MB 287ms 0ms go 1.24.4
go 1.go 349ms 21ms 39.5MB 337ms 0ms tinygo 0.38.0
go 2.go 469ms 3.1ms 20.0MB 457ms 0ms tinygo 0.38.0
go 2.go 747ms 5.8ms 21.7MB 733ms 10ms go 1.24.4
ocaml 1.ml 957ms 3.4ms 550.3MB 900ms 43ms ocaml 5.3.0
ocaml 2.ml 1886ms 14ms 18.9MB 1873ms 0ms ocaml 5.3.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 57ms 3.3ms 21.5MB 50ms 0ms go 1.24.4
go 1.go 64ms 4.2ms 10.1MB 53ms 0ms tinygo 0.38.0
go 2.go 117ms 4.5ms 4.1MB 110ms 0ms tinygo 0.38.0
go 2.go 187ms 2.3ms 6.3MB 177ms 0ms go 1.24.4
ocaml 1.ml 191ms 3.0ms 141.6MB 170ms 10ms ocaml 5.3.0
ocaml 2.ml 471ms 4.3ms 9.1MB 460ms 0ms ocaml 5.3.0

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go timeout 0.0ms 122.3MB 4983ms 43ms go 1.24.4
go 3.go timeout 0.0ms 85.0MB 4973ms 10ms tinygo 0.38.0
ocaml 2.ml timeout 0.0ms 462.9MB 4830ms 153ms ocaml 5.3.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 549ms 4.5ms 57.1MB 513ms 23ms ocaml 5.3.0
go 3.go 1798ms 95ms 20.2MB 1780ms 27ms go 1.24.4
go 3.go 2264ms 20ms 23.3MB 2247ms 0ms tinygo 0.38.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 1917ms 15ms 5.5MB 7387ms 13ms go 1.24.4
go 1.go 3646ms 8.0ms 5.6MB 3637ms 0ms go 1.24.4
ocaml 2.ml 4582ms 24ms 6.4MB 4570ms 0ms ocaml 5.3.0
go 1.go timeout 0.0ms 0.5MB 4990ms 0ms tinygo 0.38.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 481ms 1.8ms 5.6MB 1843ms 0ms go 1.24.4
go 1.go 915ms 1.3ms 3.5MB 907ms 0ms go 1.24.4
ocaml 2.ml 1159ms 5.5ms 6.1MB 1150ms 0ms ocaml 5.3.0
go 1.go 1397ms 1.7ms 0.4MB 1387ms 0ms tinygo 0.38.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 126ms 0.7ms 5.6MB 450ms 0ms go 1.24.4
go 1.go 231ms 1.9ms 3.5MB 220ms 0ms go 1.24.4
ocaml 2.ml 294ms 4.6ms 5.2MB 283ms 0ms ocaml 5.3.0
go 1.go 351ms 0.1ms 0.4MB 340ms 0ms tinygo 0.38.0