OCaml VS Ruby benchmarks

Current benchmark data was generated on Thu May 04 2023, 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
ocaml 1.ml timeout 0.0ms 145.4MB 4903ms 73ms ocaml 5.0.0
ruby 1.rb timeout 0.0ms 72.7MB 4957ms 27ms ruby 3.2.2
ruby 1.rb timeout 0.0ms 82.1MB 4917ms 63ms ruby/yjit 3.2.2
ruby 1.rb timeout 0.0ms 493.5MB 8423ms 347ms truffleruby 22.3.1

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 359ms 8.8ms 22.9MB 337ms 7ms ocaml 5.0.0
ruby 1.rb 625ms 33ms 40.7MB 590ms 20ms ruby/yjit 3.2.2
ruby 1.rb 1054ms 21ms 40.2MB 1020ms 17ms ruby 3.2.2
ruby 1-m.rb 1308ms 42ms 429.5MB 2093ms 207ms truffleruby 22.3.1

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 3637ms 2.2ms 2.7MB 3620ms 0ms ocaml 5.0.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 303ms 0.9ms 2.8MB 290ms 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 387ms 4.7ms 22.7MB 360ms 7ms ocaml 5.0.0
ruby 6.rb 2402ms 31ms 43.5MB 2360ms 23ms ruby/yjit 3.2.2
ruby 6-m.rb 3067ms 177ms 363.7MB 5537ms 270ms truffleruby 22.3.1
ruby 6.rb 4221ms 19ms 43.1MB 4183ms 20ms ruby 3.2.2

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 6.ml 42ms 0.4ms 4.9MB 30ms 0ms ocaml 5.0.0
ruby 6.rb 317ms 2.2ms 35.0MB 287ms 13ms ruby/yjit 3.2.2
ruby 6.rb 492ms 0.7ms 34.5MB 467ms 10ms ruby 3.2.2
ruby 6-m.rb 960ms 14ms 318.2MB 1630ms 130ms truffleruby 22.3.1

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 2.9ms 0.5ms 2.7MB 0ms 0ms ocaml 5.0.0
ruby 1.rb 57ms 5.5ms 157.3MB 30ms 34ms truffleruby 22.3.1
ruby 1.rb 75ms 0.9ms 32.1MB 44ms 18ms ruby 3.2.2
ruby 1.rb 81ms 4.0ms 32.2MB 50ms 16ms ruby/yjit 3.2.2

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 250ms 4.9ms 6.7MB 240ms 0ms ocaml 5.0.0
ruby 1.rb 473ms 15ms 32.9MB 450ms 7ms ruby/yjit 3.2.2
ruby 1.rb 658ms 7.7ms 32.4MB 633ms 7ms ruby 3.2.2
ruby 1-m.rb 985ms 50ms 320.7MB 1427ms 120ms truffleruby 22.3.1

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 727ms 1.6ms 6.7MB 717ms 0ms ocaml 5.0.0
ruby 1.rb 1241ms 4.1ms 32.9MB 1213ms 17ms ruby/yjit 3.2.2
ruby 1.rb 1814ms 14ms 32.4MB 1790ms 10ms ruby 3.2.2
ruby 1.rb 1843ms 9.4ms 374.4MB 2410ms 177ms truffleruby 22.3.1

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 110ms 0.4ms 6.0MB 93ms 0ms ocaml 5.0.0
ruby 1.rb 272ms 2.5ms 32.8MB 243ms 13ms ruby/yjit 3.2.2
ruby 1.rb 363ms 3.1ms 32.3MB 333ms 17ms ruby 3.2.2
ruby 1-m.rb 721ms 29ms 322.6MB 1060ms 123ms truffleruby 22.3.1

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 1931ms 14ms 69.1MB 1880ms 30ms ocaml 5.0.0
ocaml 2.ml 3617ms 28ms 74.2MB 3557ms 43ms ocaml 5.0.0
ruby 1.rb timeout 0.0ms 96.4MB 4937ms 47ms ruby 3.2.2
ruby 1.rb timeout 0.0ms 96.9MB 4920ms 60ms ruby/yjit 3.2.2
ruby 1.rb timeout 0.0ms 523.5MB 9013ms 297ms truffleruby 22.3.1

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 275ms 3.8ms 25.6MB 253ms 3ms ocaml 5.0.0
ocaml 2.ml 629ms 19ms 30.1MB 610ms 7ms ocaml 5.0.0
ruby 1-m.rb 4022ms 46ms 591.0MB 7290ms 320ms truffleruby 22.3.1
ruby 1.rb 4150ms 14ms 53.6MB 4097ms 37ms ruby/yjit 3.2.2
ruby 1.rb 4968ms 17ms 52.8MB 4920ms 30ms ruby 3.2.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 546ms 8.2ms 2.9MB 533ms 0ms ocaml 5.0.0
ruby 2.rb 1283ms 37ms 320.7MB 1533ms 127ms truffleruby 22.3.1
ruby 2.rb timeout 0.0ms 32.1MB 4970ms 17ms ruby 3.2.2
ruby 2.rb timeout 0.0ms 32.9MB 4957ms 23ms ruby/yjit 3.2.2

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 59ms 0.7ms 2.8MB 50ms 0ms ocaml 5.0.0
ruby 2-m.rb 457ms 19ms 301.8MB 693ms 93ms truffleruby 22.3.1
ruby 2.rb 2111ms 10ms 32.9MB 2067ms 23ms ruby/yjit 3.2.2
ruby 2.rb 3201ms 26ms 32.2MB 3180ms 7ms ruby 3.2.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 2718ms 31ms 19.1MB 2703ms 0ms ocaml 5.0.0
ocaml 1.ml 3571ms 30ms 550.6MB 3400ms 157ms ocaml 5.0.0
ruby 1.rb timeout 0.0ms 344.6MB 4830ms 147ms ruby 3.2.2
ruby 1.rb timeout 0.0ms 345.2MB 4813ms 163ms ruby/yjit 3.2.2
ruby 1.rb timeout 0.0ms 684.3MB 4993ms 237ms truffleruby 22.3.1

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 640ms 4.4ms 9.3MB 627ms 0ms ocaml 5.0.0
ocaml 1.ml 763ms 24ms 140.2MB 713ms 30ms ocaml 5.0.0
ruby 1.rb 3763ms 62ms 428.9MB 4377ms 187ms truffleruby 22.3.1
ruby 1.rb timeout 0.0ms 150.9MB 4913ms 70ms ruby 3.2.2
ruby 1.rb timeout 0.0ms 151.4MB 4907ms 70ms ruby/yjit 3.2.2

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 181.9MB 4887ms 90ms ocaml 5.0.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 715ms 2.6ms 52.5MB 673ms 27ms ocaml 5.0.0

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.2MB 4987ms 0ms ocaml 5.0.0
ruby 4.rb timeout 0.0ms 32.1MB 4973ms 10ms ruby 3.2.2
ruby 4.rb timeout 0.0ms 32.7MB 4967ms 13ms ruby/yjit 3.2.2
ruby 4.rb timeout 0.0ms 362.6MB 5230ms 183ms truffleruby 22.3.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 1540ms 14ms 3.5MB 1527ms 0ms ocaml 5.0.0
ruby 4.rb timeout 0.0ms 32.1MB 4970ms 13ms ruby 3.2.2
ruby 4.rb timeout 0.0ms 32.7MB 4970ms 10ms ruby/yjit 3.2.2
ruby 4.rb timeout 0.0ms 432.3MB 5530ms 197ms truffleruby 22.3.1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 2.ml 394ms 0.4ms 3.3MB 380ms 0ms ocaml 5.0.0
ruby 4.rb 3234ms 30ms 410.8MB 3887ms 177ms truffleruby 22.3.1
ruby 4.rb timeout 0.0ms 32.4MB 4967ms 13ms ruby 3.2.2
ruby 4.rb timeout 0.0ms 32.7MB 4960ms 17ms ruby/yjit 3.2.2