OCaml VS Crystal 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
crystal 1.cr 2438ms 1.7ms 64.3MB 2393ms 23ms crystal 1.7.2
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
crystal 1.cr 185ms 11ms 11.0MB 167ms 0ms crystal 1.7.2
ocaml 1.ml 395ms 6.2ms 22.9MB 363ms 13ms 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 4303ms 54ms 2.8MB 4290ms 0ms ocaml 5.0.0
crystal 1.cr 4460ms 4.4ms 3.0MB 4447ms 0ms crystal 1.7.2

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
crystal 1.cr 372ms 15ms 3.0MB 360ms 0ms crystal 1.7.2

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
crystal 2.cr 873ms 17ms 3.1MB 757ms 100ms crystal 1.7.2
crystal 1.cr 1124ms 3.1ms 14.6MB 967ms 137ms crystal 1.7.2

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
crystal 2.cr 91ms 0.9ms 3.2MB 73ms 7ms crystal 1.7.2
crystal 1.cr 117ms 0.6ms 4.5MB 90ms 17ms crystal 1.7.2

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 2.6ms 0.5ms 3.0MB 0ms 0ms crystal 1.7.2
ocaml 1.ml 2.6ms 0.9ms 2.9MB 0ms 0ms ocaml 5.0.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 0-unsafe.cr 69ms 3.1ms 3.0MB 57ms 0ms crystal 1.7.2
crystal 1.cr 113ms 1.8ms 3.0MB 100ms 0ms crystal 1.7.2
ocaml 1.ml 290ms 2.9ms 6.7MB 277ms 0ms ocaml 5.0.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 0-unsafe.cr 195ms 4.7ms 3.0MB 180ms 0ms crystal 1.7.2
crystal 1.cr 324ms 1.4ms 3.0MB 310ms 0ms crystal 1.7.2
ocaml 1.ml 860ms 8.8ms 6.8MB 847ms 0ms ocaml 5.0.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 0-unsafe.cr 36ms 2.2ms 2.9MB 23ms 0ms crystal 1.7.2
crystal 1.cr 56ms 0.1ms 2.9MB 47ms 0ms crystal 1.7.2
ocaml 1.ml 130ms 0.3ms 5.9MB 120ms 0ms ocaml 5.0.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 1790ms 9.6ms 64.3MB 1750ms 17ms crystal 1.7.2
ocaml 1.ml 2018ms 8.8ms 69.1MB 1967ms 33ms ocaml 5.0.0
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
ocaml 1.ml 296ms 3.1ms 25.8MB 263ms 10ms ocaml 5.0.0
crystal 1.cr 320ms 17ms 22.1MB 300ms 7ms crystal 1.7.2
ocaml 2.ml 685ms 5.7ms 30.2MB 653ms 13ms ocaml 5.0.0

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
crystal 1.cr 670ms 3.5ms 2.9MB 657ms 0ms crystal 1.7.2
crystal 2.cr 694ms 9.6ms 3.0MB 683ms 0ms crystal 1.7.2

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 73ms 1.3ms 3.0MB 60ms 0ms crystal 1.7.2
ocaml 1.ml 74ms 3.1ms 2.9MB 63ms 0ms ocaml 5.0.0
crystal 2.cr 79ms 4.1ms 2.9MB 70ms 0ms crystal 1.7.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 2.cr 513ms 4.0ms 7.8MB 500ms 0ms crystal 1.7.2
crystal 1.cr 1150ms 55ms 41.9MB 1130ms 7ms crystal 1.7.2
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
crystal 2.cr 117ms 2.4ms 4.1MB 103ms 0ms crystal 1.7.2
crystal 1.cr 175ms 1.0ms 12.9MB 160ms 0ms crystal 1.7.2
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
crystal 1.cr 2759ms 1.3ms 174.0MB 2687ms 57ms crystal 1.7.2
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
crystal 1.cr 287ms 1.0ms 32.1MB 260ms 10ms crystal 1.7.2
ocaml 2.ml 818ms 6.0ms 52.5MB 780ms 20ms ocaml 5.0.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr timeout 0.0ms 4.0MB 4977ms 3ms crystal 1.7.2
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
crystal 1.cr 1847ms 33ms 3.7MB 1837ms 0ms crystal 1.7.2

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 466ms 4.6ms 3.6MB 453ms 0ms crystal 1.7.2
ocaml 2.ml 475ms 16ms 3.4MB 460ms 0ms ocaml 5.0.0