Ruby VS Elixir benchmarks

Current benchmark data was generated on Thu Sep 22 2022, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz (Model 106)

* -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
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1-m.rb 893ms 4.8ms 400.8MB 1437ms 140ms truffleruby 22.2.0
ruby 1.rb 909ms 3.9ms 292.0MB 757ms 133ms ruby/yjit 3.1.2
ruby 1.rb 973ms 6.2ms 35.5MB 940ms 17ms ruby 3.1.2

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 3096ms 14ms 336.6MB 2900ms 177ms ruby/yjit 3.1.2
ruby 1.rb 3554ms 6.1ms 80.2MB 3490ms 50ms ruby 3.1.2
elixir 1.ex 4743ms 26ms 53.5MB 4777ms 117ms elixir 13.1.0
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 240ms 4.4ms 42.2MB 200ms 20ms ruby 3.1.2
ruby 1.rb 382ms 1.7ms 298.8MB 227ms 143ms ruby/yjit 3.1.2
elixir 1.ex 509ms 4.1ms 50.6MB 543ms 43ms elixir 13.1.0
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 6.rb 2845ms 14ms 296.0MB 2673ms 153ms ruby/yjit 3.1.2
ruby 6.rb 4360ms 38ms 39.4MB 4327ms 20ms ruby 3.1.2
ruby 6.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 6.rb 504ms 2.6ms 287.6MB 353ms 137ms ruby/yjit 3.1.2
ruby 6.rb 505ms 3.9ms 31.1MB 477ms 13ms ruby 3.1.2
ruby 6-m.rb 1331ms 21ms 387.2MB 2350ms 107ms truffleruby 22.2.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 41ms 1.1ms 145.7MB 22ms 16ms truffleruby 22.2.0
ruby 1.rb 70ms 0.9ms 29.9MB 48ms 10ms ruby 3.1.2
elixir 1.ex 216ms 4.1ms 47.8MB 240ms 34ms elixir 13.1.0
ruby 1.rb 240ms 1.6ms 286.6MB 100ms 124ms ruby/yjit 3.1.2

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 430ms 1.4ms 49.3MB 397ms 23ms ruby 3.1.2
ruby 1.rb 600ms 1.7ms 305.1MB 437ms 143ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 3872ms 2.8ms 160.1MB 3780ms 73ms ruby 3.1.2
ruby 1.rb 4140ms 173ms 418.9MB 3917ms 207ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 609ms 6.2ms 30.2MB 580ms 10ms ruby 3.1.2
ruby 1.rb 627ms 4.1ms 286.6MB 487ms 127ms ruby/yjit 3.1.2
ruby 1-m.rb 746ms 6.4ms 314.0MB 1080ms 93ms truffleruby 22.2.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 1388ms 18ms 286.8MB 1247ms 127ms ruby/yjit 3.1.2
ruby 1.rb 1391ms 3.8ms 339.8MB 1920ms 120ms truffleruby 22.2.0
ruby 1.rb 1675ms 30ms 30.2MB 1650ms 13ms ruby 3.1.2

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 347ms 5.8ms 29.9MB 327ms 7ms ruby 3.1.2
ruby 1.rb 433ms 1.2ms 286.7MB 290ms 127ms ruby/yjit 3.1.2
ruby 1-m.rb 538ms 7.6ms 297.4MB 823ms 73ms truffleruby 22.2.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1-m.rb 3161ms 37ms 580.5MB 5767ms 237ms truffleruby 22.2.0
ruby 1.rb 3960ms 18ms 300.9MB 3797ms 143ms ruby/yjit 3.1.2
ruby 1.rb 4792ms 15ms 44.4MB 4750ms 30ms ruby 3.1.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 2.rb 1108ms 5.4ms 317.8MB 1390ms 100ms truffleruby 22.2.0
ruby 2.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 2.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 2-m.rb 421ms 1.4ms 300.5MB 650ms 100ms truffleruby 22.2.0
ruby 2.rb 2353ms 2.0ms 286.7MB 2207ms 123ms ruby/yjit 3.1.2
ruby 2.rb 3241ms 15ms 29.9MB 3217ms 10ms ruby 3.1.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 3198ms 35ms 463.2MB 3600ms 157ms truffleruby 22.2.0
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
elixir 1.ex timeout 0.0ms 0.0MB 0ms 0ms elixir 13.1.0
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
elixir 1.ex 1308ms 3.9ms 46.6MB 1347ms 133ms elixir 13.1.0
ruby 1-m.rb 1925ms 1.4ms 383.9MB 3523ms 147ms truffleruby 22.2.0
ruby 1.rb 2499ms 1.8ms 161.8MB 2413ms 67ms ruby 3.1.2
ruby 1.rb 2661ms 4.8ms 420.8MB 2450ms 193ms ruby/yjit 3.1.2

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
elixir 1.ex timeout 0.0ms 0.0MB 0ms 0ms elixir 13.1.0
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
elixir 1.ex timeout 0.0ms 0.0MB 0ms 0ms elixir 13.1.0
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 4.rb 2456ms 33ms 462.5MB 2987ms 150ms truffleruby 22.2.0
elixir 1.ex timeout 0.0ms 0.0MB 0ms 0ms elixir 13.1.0
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2