Ruby VS Kotlin benchmarks

Current benchmark data was generated on Mon Apr 14 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
kotlin 1.kt 513ms 4.4ms 577.8MB 603ms 107ms kotlin/jvm 21
kotlin 1.kt 4515ms 38ms 146.1MB 4703ms 67ms kotlin/native 2.1.20
ruby 1.rb 4815ms 21ms 109.4MB 4710ms 90ms ruby/yjit 3.4.2
ruby 1.rb timeout 0.0ms 70.5MB 4953ms 37ms ruby 3.4.2
ruby 1.rb timeout 0.0ms 758.8MB 6567ms 693ms truffleruby 24.2.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 126ms 1.8ms 161.2MB 150ms 37ms kotlin/jvm 21
kotlin 1.kt 318ms 32ms 17.9MB 327ms 7ms kotlin/native 2.1.20
ruby 1.rb 492ms 5.0ms 20.4MB 467ms 10ms ruby/yjit 3.4.2
ruby 1-m.rb 537ms 66ms 418.7MB 1060ms 157ms truffleruby 24.2.0
ruby 1.rb 937ms 8.8ms 19.6MB 910ms 13ms ruby 3.4.2

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 1460ms 7.9ms 63.8MB 1380ms 63ms ruby/yjit 3.4.2
ruby 1.rb 1856ms 18ms 63.1MB 1783ms 60ms ruby 3.4.2
kotlin 2-m.kt 2184ms 180ms 244.6MB 8133ms 130ms kotlin/jvm 21
kotlin 1.kt 2217ms 57ms 220.3MB 3067ms 70ms kotlin/jvm 21
kotlin 2-m.kt 4498ms 30ms 21.5MB 14707ms 610ms kotlin/native 2.1.20
kotlin 1.kt timeout 0.0ms 17.4MB 5523ms 30ms kotlin/native 2.1.20
ruby 1.rb timeout 0.0ms 357.5MB 4680ms 1437ms truffleruby 24.2.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 155ms 0.2ms 25.8MB 127ms 17ms ruby/yjit 3.4.2
ruby 1.rb 180ms 0.8ms 25.1MB 150ms 17ms ruby 3.4.2
kotlin 2-m.kt 253ms 6.4ms 21.3MB 847ms 40ms kotlin/native 2.1.20
kotlin 1.kt 409ms 11ms 17.4MB 420ms 10ms kotlin/native 2.1.20
kotlin 1-m.kt 492ms 12ms 77.2MB 1140ms 43ms kotlin/jvm 21
kotlin 2-m.kt 969ms 186ms 109.2MB 3360ms 83ms kotlin/jvm 21
ruby 1.rb timeout 0.0ms 332.3MB 4803ms 1357ms truffleruby 24.2.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 6.rb 2050ms 4.6ms 23.0MB 2020ms 13ms ruby/yjit 3.4.2
ruby 6-m.rb 2229ms 245ms 437.5MB 5773ms 363ms truffleruby 24.2.0
ruby 6.rb 3848ms 19ms 22.4MB 3823ms 13ms ruby 3.4.2

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 6.rb 267ms 5.3ms 15.0MB 250ms 0ms ruby/yjit 3.4.2
ruby 6.rb 439ms 1.1ms 14.5MB 420ms 3ms ruby 3.4.2
ruby 6-m.rb 828ms 16ms 375.5MB 2057ms 180ms truffleruby 24.2.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 2.1ms 0.1ms 3.1MB 0ms 0ms kotlin/native 2.1.20
ruby 1.rb 35ms 0.5ms 141.8MB 14ms 24ms truffleruby 24.2.0
ruby 1.rb 51ms 1.1ms 12.9MB 38ms 0ms ruby 3.4.2
ruby 1.rb 53ms 1.6ms 13.1MB 38ms 2ms ruby/yjit 3.4.2
kotlin 1.kt 67ms 2.3ms 47.7MB 82ms 16ms kotlin/jvm 21

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 249ms 0.3ms 29.0MB 220ms 13ms ruby/yjit 3.4.2
ruby 1.rb 254ms 0.5ms 27.4MB 220ms 20ms ruby 3.4.2
kotlin 1-m.kt 773ms 88ms 172.2MB 2063ms 87ms kotlin/jvm 21
ruby 1-m.rb 4445ms 295ms 567.1MB 11670ms 337ms truffleruby 24.2.0

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1-m.kt 1862ms 58ms 671.6MB 4417ms 173ms kotlin/jvm 21
ruby 1.rb 2093ms 6.5ms 135.0MB 2003ms 77ms ruby/yjit 3.4.2
ruby 1.rb 2093ms 7.0ms 134.5MB 2003ms 73ms ruby 3.4.2
ruby 1.rb timeout 0.0ms 522.9MB 13260ms 347ms truffleruby 24.2.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2.kt 171ms 2.7ms 12.4MB 173ms 0ms kotlin/native 2.1.20
kotlin 1-m.kt 200ms 3.0ms 96.7MB 333ms 27ms kotlin/jvm 21
kotlin 2-m.kt 212ms 8.2ms 105.3MB 453ms 40ms kotlin/jvm 21
ruby 1.rb 334ms 6.3ms 13.5MB 317ms 3ms ruby/yjit 3.4.2
kotlin 1.kt 357ms 2.2ms 12.5MB 363ms 3ms kotlin/native 2.1.20
ruby 1.rb 528ms 4.6ms 12.9MB 513ms 3ms ruby 3.4.2
ruby 1-m.rb 680ms 43ms 373.6MB 1197ms 137ms truffleruby 24.2.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2-m.kt 325ms 2.7ms 215.9MB 557ms 50ms kotlin/jvm 21
kotlin 1.kt 344ms 2.7ms 204.8MB 463ms 40ms kotlin/jvm 21
kotlin 2.kt 476ms 6.0ms 12.6MB 507ms 3ms kotlin/native 2.1.20
ruby 1.rb 883ms 3.5ms 13.5MB 860ms 10ms ruby/yjit 3.4.2
kotlin 1.kt 1043ms 15ms 12.6MB 1080ms 3ms kotlin/native 2.1.20
ruby 1-m.rb 1207ms 46ms 407.2MB 1677ms 157ms truffleruby 24.2.0
ruby 1.rb 1475ms 9.5ms 13.0MB 1453ms 10ms ruby 3.4.2

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2.kt 94ms 0.7ms 12.8MB 87ms 3ms kotlin/native 2.1.20
kotlin 1.kt 122ms 2.7ms 12.9MB 117ms 0ms kotlin/native 2.1.20
kotlin 1-m.kt 159ms 1.4ms 92.7MB 320ms 20ms kotlin/jvm 21
kotlin 2-m.kt 167ms 2.2ms 98.3MB 350ms 37ms kotlin/jvm 21
ruby 1.rb 192ms 1.4ms 13.5MB 177ms 7ms ruby/yjit 3.4.2
ruby 1.rb 294ms 2.8ms 12.9MB 280ms 3ms ruby 3.4.2
ruby 1-m.rb 515ms 15ms 357.6MB 1040ms 137ms truffleruby 24.2.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 391ms 4.1ms 682.5MB 453ms 93ms kotlin/jvm 21
kotlin 1.kt 2170ms 19ms 88.8MB 2273ms 40ms kotlin/native 2.1.20
ruby 1-m.rb 4155ms 538ms 542.6MB 10537ms 360ms truffleruby 24.2.0
ruby 1.rb timeout 0.0ms 93.6MB 4933ms 50ms ruby 3.4.2
ruby 1.rb timeout 0.0ms 94.1MB 4943ms 40ms ruby/yjit 3.4.2

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1-m.kt 163ms 0.8ms 209.4MB 213ms 50ms kotlin/jvm 21
kotlin 1.kt 426ms 7.1ms 25.7MB 437ms 10ms kotlin/native 2.1.20
ruby 1-m.rb 2026ms 131ms 594.1MB 5157ms 270ms truffleruby 24.2.0
ruby 1.rb 3422ms 26ms 38.3MB 3383ms 23ms ruby/yjit 3.4.2
ruby 1.rb 4463ms 59ms 37.8MB 4427ms 27ms ruby 3.4.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1n.kt 352ms 1.7ms 3.5MB 340ms 0ms kotlin/native 2.1.20
kotlin 1.kt 448ms 1.3ms 49.3MB 493ms 17ms kotlin/jvm 21
ruby 2.rb 825ms 4.5ms 309.8MB 1053ms 117ms truffleruby 24.2.0
ruby 2.rb timeout 0.0ms 12.9MB 4987ms 0ms ruby 3.4.2
ruby 2.rb timeout 0.0ms 13.5MB 4983ms 3ms ruby/yjit 3.4.2

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1n.kt 39ms 0.9ms 3.5MB 30ms 0ms kotlin/native 2.1.20
kotlin 1-m.kt 126ms 3.5ms 49.4MB 173ms 20ms kotlin/jvm 21
ruby 2-m.rb 308ms 6.2ms 310.0MB 540ms 117ms truffleruby 24.2.0
ruby 2.rb 1062ms 3.2ms 13.5MB 1047ms 3ms ruby/yjit 3.4.2
ruby 2.rb 2806ms 75ms 12.9MB 2787ms 3ms ruby 3.4.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb timeout 0.0ms 325.4MB 4860ms 130ms ruby 3.4.2
ruby 1.rb timeout 0.0ms 327.0MB 4853ms 137ms ruby/yjit 3.4.2
ruby 1.rb timeout 0.0ms 703.0MB 5090ms 140ms truffleruby 24.2.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 1725ms 19ms 476.7MB 2387ms 160ms truffleruby 24.2.0
ruby 1.rb 3412ms 46ms 131.8MB 3323ms 73ms ruby/yjit 3.4.2
ruby 1.rb 4494ms 36ms 131.1MB 4403ms 77ms ruby 3.4.2

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 3792ms 49ms 385.9MB 4713ms 107ms kotlin/jvm 21
kotlin 1n.kt timeout 0.0ms 27.0MB 4077ms 1520ms kotlin/native 2.1.20
kotlin 2n.kt timeout 0.0ms 30.4MB 5163ms 130ms kotlin/native 2.1.20
ruby 1.rb timeout 0.0ms 46.6MB 4920ms 60ms ruby 3.4.2
ruby 1.rb timeout 0.0ms 127.6MB 4830ms 157ms ruby/yjit 3.4.2
ruby 1.rb timeout 0.0ms 437.3MB 13257ms 400ms truffleruby 24.2.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1-m.kt 992ms 27ms 355.5MB 1823ms 100ms kotlin/jvm 21
ruby 1.rb 1663ms 2.6ms 46.0MB 1623ms 27ms ruby 3.4.2
ruby 1.rb 1695ms 86ms 126.8MB 1620ms 60ms ruby/yjit 3.4.2
ruby 1-m.rb 1731ms 175ms 412.7MB 4540ms 227ms truffleruby 24.2.0
kotlin 1n.kt timeout 0.0ms 26.6MB 4110ms 1483ms kotlin/native 2.1.20
kotlin 2n.kt timeout 0.0ms 30.9MB 5130ms 163ms kotlin/native 2.1.20

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 4.rb timeout 0.0ms 13.0MB 4983ms 3ms ruby 3.4.2
ruby 4.rb timeout 0.0ms 13.5MB 4983ms 7ms ruby/yjit 3.4.2
ruby 4.rb timeout 0.0ms 434.6MB 5167ms 233ms truffleruby 24.2.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 4.rb 4868ms 23ms 439.6MB 5153ms 217ms truffleruby 24.2.0
ruby 4.rb timeout 0.0ms 13.0MB 4987ms 3ms ruby 3.4.2
ruby 4.rb timeout 0.0ms 13.5MB 4980ms 3ms ruby/yjit 3.4.2

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 4.rb 1435ms 5.1ms 375.6MB 1770ms 137ms truffleruby 24.2.0
ruby 4.rb timeout 0.0ms 13.0MB 4983ms 3ms ruby 3.4.2
ruby 4.rb timeout 0.0ms 13.8MB 4980ms 3ms ruby/yjit 3.4.2