Ruby VS Go 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
go 1.go 3847ms 17ms 45.6MB 5503ms 83ms go 1.19.5
go 1.go timeout 0.0ms 39.4MB 4970ms 7ms tinygo 0.25.0
ruby 1.rb timeout 0.0ms 72.6MB 4940ms 40ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 82.1MB 4923ms 57ms ruby/yjit 3.2.0
ruby 1.rb timeout 0.0ms 471.3MB 8477ms 293ms truffleruby 22.3.1

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 324ms 2.4ms 8.3MB 417ms 3ms go 1.19.5
go 1.go 438ms 0.7ms 5.9MB 423ms 0ms tinygo 0.25.0
ruby 1.rb 718ms 9.3ms 40.7MB 673ms 30ms ruby/yjit 3.2.0
ruby 1.rb 1269ms 18ms 40.3MB 1233ms 20ms ruby 3.2.0
ruby 1-m.rb 1341ms 27ms 400.1MB 2230ms 170ms truffleruby 22.3.1

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-m.go 984ms 210ms 13.6MB 1910ms 0ms go 1.19.5
go 1.go 2170ms 13ms 256.7MB 2087ms 63ms tinygo 0.25.0
ruby 1.rb 4296ms 59ms 82.8MB 4203ms 77ms ruby/yjit 3.2.0
ruby 1.rb timeout 0.0ms 81.5MB 4900ms 73ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 1103.9MB 4400ms 1323ms truffleruby 22.3.1

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1-m.go 73ms 13ms 5.4MB 117ms 0ms go 1.19.5
ruby 1.rb 292ms 1.0ms 44.9MB 247ms 33ms ruby/yjit 3.2.0
ruby 1.rb 341ms 17ms 44.5MB 290ms 33ms ruby 3.2.0
go 1.go 346ms 2.1ms 65.6MB 307ms 23ms tinygo 0.25.0
ruby 1.rb timeout 0.0ms 1096.9MB 4293ms 1420ms truffleruby 22.3.1

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3-m.go 251ms 0.7ms 2.9MB 450ms 0ms go 1.19.5
ruby 6.rb 2828ms 11ms 43.6MB 2787ms 27ms ruby/yjit 3.2.0
ruby 6-m.rb 3219ms 20ms 392.0MB 5753ms 340ms truffleruby 22.3.1
ruby 6.rb timeout 0.0ms 42.9MB 4957ms 23ms ruby 3.2.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 32ms 0.4ms 2.9MB 40ms 0ms go 1.19.5
ruby 6.rb 368ms 4.1ms 35.0MB 337ms 17ms ruby/yjit 3.2.0
ruby 6.rb 594ms 3.7ms 34.4MB 557ms 17ms ruby 3.2.0
ruby 6-m.rb 1035ms 11ms 324.2MB 1757ms 143ms truffleruby 22.3.1

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 1.9ms 0.9ms 0.2MB 0ms 0ms tinygo 0.25.0
go 1.go 3.4ms 0.5ms 2.9MB 0ms 0ms go 1.19.5
ruby 1.rb 54ms 1.8ms 153.4MB 30ms 28ms truffleruby 22.3.1
ruby 1.rb 87ms 1.1ms 32.1MB 52ms 18ms ruby 3.2.0
ruby 1.rb 91ms 4.1ms 32.3MB 64ms 14ms ruby/yjit 3.2.0

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2-ffi.go 83ms 6.6ms 42.1MB 60ms 17ms go 1.19.5
go 1.go 213ms 3.5ms 18.8MB 197ms 3ms go 1.19.5
ruby 1.rb 536ms 9.1ms 52.0MB 493ms 27ms ruby/yjit 3.2.0
ruby 1.rb 539ms 2.7ms 54.3MB 493ms 27ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 429.6MB 9103ms 237ms truffleruby 22.3.1

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2-ffi.go 483ms 20ms 182.5MB 440ms 133ms go 1.19.5
go 1.go 1288ms 8.1ms 105.2MB 1253ms 83ms go 1.19.5
ruby 1.rb 4869ms 23ms 174.3MB 4730ms 123ms ruby/yjit 3.2.0
ruby 1.rb 4894ms 50ms 175.2MB 4767ms 110ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 404.1MB 9173ms 250ms truffleruby 22.3.1

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 195ms 4.6ms 0.3MB 183ms 0ms tinygo 0.25.0
go 3.go 201ms 2.4ms 3.4MB 187ms 0ms go 1.19.5
ruby 1.rb 547ms 7.6ms 33.0MB 513ms 20ms ruby/yjit 3.2.0
ruby 1.rb 783ms 2.8ms 32.4MB 753ms 13ms ruby 3.2.0
ruby 1-m.rb 991ms 25ms 326.0MB 1430ms 137ms truffleruby 22.3.1

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 566ms 1.0ms 0.3MB 553ms 0ms tinygo 0.25.0
go 3.go 589ms 3.6ms 3.4MB 573ms 0ms go 1.19.5
ruby 1.rb 1475ms 1.9ms 33.0MB 1447ms 13ms ruby/yjit 3.2.0
ruby 1.rb 1943ms 72ms 333.2MB 2463ms 183ms truffleruby 22.3.1
ruby 1.rb 2117ms 13ms 32.4MB 2083ms 17ms ruby 3.2.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 3.go 99ms 0.4ms 0.0MB 90ms 0ms tinygo 0.25.0
go 3.go 108ms 3.8ms 4.1MB 100ms 0ms go 1.19.5
ruby 1.rb 319ms 2.1ms 32.8MB 290ms 13ms ruby/yjit 3.2.0
ruby 1.rb 426ms 2.6ms 32.3MB 397ms 10ms ruby 3.2.0
ruby 1-m.rb 739ms 68ms 311.2MB 1117ms 130ms truffleruby 22.3.1

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 2523ms 14ms 38.2MB 3530ms 67ms go 1.19.5
go 2.go 2861ms 21ms 45.1MB 4040ms 80ms go 1.19.5
go 1.go 4946ms 23ms 212.6MB 4880ms 50ms tinygo 0.25.0
go 2.go timeout 0.0ms 51.3MB 4973ms 3ms tinygo 0.25.0
ruby 1.rb timeout 0.0ms 96.5MB 4910ms 73ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 97.0MB 4913ms 70ms ruby/yjit 3.2.0
ruby 1.rb timeout 0.0ms 511.3MB 9013ms 283ms truffleruby 22.3.1

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 535ms 12ms 12.1MB 713ms 20ms go 1.19.5
go 2.go 606ms 2.8ms 13.4MB 837ms 7ms go 1.19.5
go 1.go 864ms 21ms 51.9MB 837ms 7ms tinygo 0.25.0
go 2.go 1659ms 8.8ms 39.3MB 1637ms 7ms tinygo 0.25.0
ruby 1-m.rb 4229ms 57ms 589.3MB 7687ms 320ms truffleruby 22.3.1
ruby 1.rb 4784ms 22ms 53.7MB 4710ms 57ms ruby/yjit 3.2.0
ruby 1.rb timeout 0.0ms 52.8MB 4943ms 37ms ruby 3.2.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 599ms 3.1ms 2.9MB 587ms 0ms go 1.19.5
go 1.go 839ms 2.3ms 2.0MB 830ms 0ms tinygo 0.25.0
ruby 2.rb 1435ms 12ms 298.5MB 1713ms 100ms truffleruby 22.3.1
ruby 2.rb timeout 0.0ms 32.2MB 4970ms 13ms ruby 3.2.0
ruby 2.rb timeout 0.0ms 33.0MB 4963ms 13ms ruby/yjit 3.2.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 65ms 1.5ms 2.9MB 50ms 0ms go 1.19.5
go 1.go 84ms 1.0ms 0.0MB 73ms 0ms tinygo 0.25.0
ruby 2-m.rb 513ms 25ms 309.9MB 770ms 127ms truffleruby 22.3.1
ruby 2.rb 2528ms 32ms 33.1MB 2487ms 23ms ruby/yjit 3.2.0
ruby 2.rb 4072ms 73ms 32.2MB 4043ms 13ms ruby 3.2.0

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 2.go 808ms 5.4ms 17.6MB 793ms 0ms tinygo 0.25.0
go 1.go 986ms 32ms 73.7MB 957ms 17ms go 1.19.5
go 1.go 1060ms 43ms 43.8MB 1027ms 10ms tinygo 0.25.0
go 2.go 1095ms 9.3ms 20.0MB 1073ms 13ms go 1.19.5
ruby 1.rb timeout 0.0ms 344.6MB 4780ms 197ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 344.9MB 4787ms 190ms ruby/yjit 3.2.0
ruby 1.rb timeout 0.0ms 682.1MB 5030ms 217ms truffleruby 22.3.1

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 1.go 142ms 8.0ms 22.2MB 120ms 3ms go 1.19.5
go 1.go 151ms 0.6ms 13.4MB 140ms 0ms tinygo 0.25.0
go 2.go 198ms 10ms 5.6MB 173ms 0ms tinygo 0.25.0
go 2.go 259ms 2.0ms 8.0MB 250ms 0ms go 1.19.5
ruby 1.rb 3780ms 6.1ms 431.4MB 4390ms 167ms truffleruby 22.3.1
ruby 1.rb timeout 0.0ms 151.0MB 4900ms 77ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 151.5MB 4893ms 90ms ruby/yjit 3.2.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 8.go 1588ms 15ms 8.5MB 1560ms 10ms go 1.19.5
ruby 1.rb timeout 0.0ms 159.1MB 4913ms 67ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 159.8MB 4903ms 73ms ruby/yjit 3.2.0
ruby 1.rb timeout 0.0ms 430.8MB 9380ms 223ms truffleruby 22.3.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 8.go 367ms 3.4ms 8.5MB 350ms 3ms go 1.19.5
ruby 1-m.rb 2551ms 7.6ms 419.5MB 4673ms 190ms truffleruby 22.3.1
ruby 1.rb 3739ms 3.7ms 158.8MB 3630ms 87ms ruby/yjit 3.2.0
ruby 1.rb 3746ms 14ms 158.0MB 3647ms 80ms ruby 3.2.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 2681ms 27ms 4.9MB 5153ms 3ms go 1.19.5
go 1.go timeout 0.0ms 5.4MB 4983ms 3ms go 1.19.5
go 1.go timeout 0.0ms 2.4MB 4983ms 0ms tinygo 0.25.0
ruby 4.rb timeout 0.0ms 32.2MB 4967ms 10ms ruby 3.2.0
ruby 4.rb timeout 0.0ms 32.9MB 4973ms 13ms ruby/yjit 3.2.0
ruby 4.rb timeout 0.0ms 404.5MB 5227ms 213ms truffleruby 22.3.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 674ms 7.1ms 3.4MB 1277ms 0ms go 1.19.5
go 1.go 1330ms 2.8ms 2.9MB 1323ms 0ms go 1.19.5
go 1.go timeout 0.0ms 0.0MB 4983ms 0ms tinygo 0.25.0
ruby 4.rb timeout 0.0ms 32.2MB 4970ms 17ms ruby 3.2.0
ruby 4.rb timeout 0.0ms 32.8MB 4957ms 20ms ruby/yjit 3.2.0
ruby 4.rb timeout 0.0ms 460.5MB 5583ms 183ms truffleruby 22.3.1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
go 4-m.go 182ms 3.8ms 2.9MB 313ms 0ms go 1.19.5
go 1.go 336ms 2.1ms 2.9MB 327ms 0ms go 1.19.5
go 1.go 1953ms 7.3ms 0.0MB 1940ms 0ms tinygo 0.25.0
ruby 4.rb 3275ms 18ms 360.5MB 3963ms 167ms truffleruby 22.3.1
ruby 4.rb timeout 0.0ms 32.0MB 4960ms 23ms ruby 3.2.0
ruby 4.rb timeout 0.0ms 32.9MB 4967ms 10ms ruby/yjit 3.2.0