Kotlin VS Ruby benchmarks

Current benchmark data was generated on Sat Jan 28 2023, 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
kotlin 1.kt 629ms 6.5ms 413.0MB 657ms 77ms kotlin/jvm 17.0.2
kotlin 1.kt timeout 0.0ms 282.5MB 8413ms 1150ms kotlin/native 1.8.0
ruby 1.rb timeout 0.0ms 72.6MB 4943ms 40ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 115.6MB 4917ms 60ms ruby/yjit 3.2.0
ruby 1.rb timeout 0.0ms 612.7MB 8020ms 290ms truffleruby 22.3.1

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 125ms 2.0ms 109.7MB 107ms 27ms kotlin/jvm 17.0.2
kotlin 1-m.kt 494ms 11ms 30.5MB 847ms 77ms kotlin/native 1.8.0
ruby 1.rb 565ms 6.7ms 40.7MB 530ms 17ms ruby/yjit 3.2.0
ruby 1.rb 1011ms 5.8ms 40.3MB 973ms 20ms ruby 3.2.0
ruby 1-m.rb 1081ms 25ms 419.3MB 1780ms 140ms truffleruby 22.3.1

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 2892ms 79ms 160.4MB 3693ms 57ms kotlin/jvm 17.0.2
kotlin 2-m.kt 3128ms 450ms 157.4MB 5980ms 57ms kotlin/jvm 17.0.2
ruby 1.rb 3205ms 134ms 82.8MB 3133ms 50ms ruby/yjit 3.2.0
ruby 1.rb 3867ms 456ms 82.1MB 3787ms 60ms ruby 3.2.0
kotlin 1.kt timeout 0.0ms 10.8MB 6177ms 300ms kotlin/native 1.8.0
kotlin 2-m.kt timeout 0.0ms 35.0MB 9297ms 150ms kotlin/native 1.8.0
ruby 1.rb timeout 0.0ms 942.2MB 4210ms 1413ms truffleruby 22.3.1

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 231ms 3.0ms 44.9MB 190ms 27ms ruby/yjit 3.2.0
ruby 1.rb 240ms 0.5ms 44.5MB 203ms 20ms ruby 3.2.0
kotlin 1-m.kt 706ms 24ms 99.1MB 1240ms 40ms kotlin/jvm 17.0.2
kotlin 2-m.kt 811ms 15ms 26.1MB 1450ms 33ms kotlin/native 1.8.0
kotlin 1.kt 1032ms 12ms 8.8MB 1270ms 57ms kotlin/native 1.8.0
kotlin 2-m.kt 1082ms 129ms 114.4MB 1967ms 50ms kotlin/jvm 17.0.2
ruby 1.rb timeout 0.0ms 908.0MB 4197ms 1183ms truffleruby 22.3.1

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 2.6ms 1.0ms 1.5MB 0ms 0ms kotlin/native 1.8.0
ruby 1.rb 45ms 2.4ms 154.4MB 18ms 30ms truffleruby 22.3.1
kotlin 1.kt 66ms 1.4ms 40.8MB 50ms 8ms kotlin/jvm 17.0.2
ruby 1.rb 72ms 1.0ms 32.2MB 50ms 10ms ruby 3.2.0
ruby 1.rb 77ms 0.9ms 32.3MB 50ms 12ms ruby/yjit 3.2.0

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt timeout 0.0ms 296.5MB 8853ms 617ms kotlin/jvm 17.0.2
kotlin 2.kt timeout 0.0ms 267.6MB 8833ms 673ms kotlin/jvm 17.0.2

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2-m.kt 2340ms 166ms 198.0MB 3627ms 210ms kotlin/jvm 17.0.2
kotlin 1-m.kt 2612ms 76ms 184.0MB 3997ms 273ms kotlin/jvm 17.0.2

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 440ms 2.6ms 52.9MB 400ms 23ms ruby 3.2.0
ruby 1.rb 461ms 9.3ms 54.5MB 410ms 30ms ruby/yjit 3.2.0
kotlin 1-m.kt 1170ms 37ms 217.4MB 2000ms 90ms kotlin/jvm 17.0.2
ruby 1.rb timeout 0.0ms 465.4MB 9110ms 200ms truffleruby 22.3.1

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 4007ms 6.6ms 174.0MB 3903ms 87ms ruby/yjit 3.2.0
ruby 1.rb 4060ms 98ms 173.9MB 3957ms 90ms ruby 3.2.0
kotlin 1.kt 4233ms 274ms 875.8MB 6110ms 223ms kotlin/jvm 17.0.2
ruby 1.rb timeout 0.0ms 432.6MB 9203ms 197ms truffleruby 22.3.1

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2-m.kt 221ms 5.0ms 113.5MB 323ms 27ms kotlin/jvm 17.0.2
kotlin 1.kt 240ms 5.8ms 109.4MB 290ms 17ms kotlin/jvm 17.0.2
kotlin 2-m.kt 442ms 3.8ms 42.5MB 727ms 13ms kotlin/native 1.8.0
ruby 1.rb 448ms 2.7ms 33.0MB 420ms 13ms ruby/yjit 3.2.0
ruby 1.rb 602ms 5.0ms 32.3MB 580ms 3ms ruby 3.2.0
ruby 1-m.rb 832ms 33ms 335.1MB 1183ms 100ms truffleruby 22.3.1
kotlin 1.kt timeout 0.0ms 15.0MB 4993ms 10ms kotlin/native 1.8.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2.kt 365ms 4.2ms 132.5MB 460ms 33ms kotlin/jvm 17.0.2
kotlin 1.kt 458ms 3.2ms 132.6MB 507ms 23ms kotlin/jvm 17.0.2
ruby 1.rb 1183ms 7.0ms 33.0MB 1157ms 10ms ruby/yjit 3.2.0
kotlin 2-m.kt 1377ms 6.7ms 145.0MB 2233ms 87ms kotlin/native 1.8.0
ruby 1.rb 1478ms 87ms 370.8MB 1977ms 150ms truffleruby 22.3.1
ruby 1.rb 1648ms 12ms 32.4MB 1620ms 10ms ruby 3.2.0
kotlin 1.kt timeout 0.0ms 15.0MB 4997ms 0ms kotlin/native 1.8.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 172ms 3.4ms 75.8MB 243ms 10ms kotlin/jvm 17.0.2
kotlin 2.kt 186ms 6.0ms 78.6MB 250ms 27ms kotlin/jvm 17.0.2
kotlin 2-m.kt 224ms 4.4ms 32.4MB 383ms 3ms kotlin/native 1.8.0
ruby 1.rb 264ms 2.9ms 32.9MB 233ms 13ms ruby/yjit 3.2.0
ruby 1.rb 334ms 3.9ms 32.3MB 307ms 17ms ruby 3.2.0
ruby 1-m.rb 619ms 11ms 311.7MB 913ms 103ms truffleruby 22.3.1
kotlin 1.kt timeout 0.0ms 17.1MB 5000ms 7ms kotlin/native 1.8.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 444ms 4.8ms 285.8MB 437ms 57ms kotlin/jvm 17.0.2
kotlin 1-m.kt 2678ms 5.5ms 138.5MB 4327ms 570ms kotlin/native 1.8.0
ruby 1.rb timeout 0.0ms 96.4MB 4933ms 47ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 97.0MB 4927ms 57ms ruby/yjit 3.2.0
ruby 1.rb timeout 0.0ms 562.9MB 9010ms 220ms truffleruby 22.3.1

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 174ms 3.5ms 221.9MB 160ms 43ms kotlin/jvm 17.0.2
kotlin 1-m.kt 516ms 7.8ms 38.4MB 817ms 87ms kotlin/native 1.8.0
ruby 1-m.rb 3464ms 95ms 580.1MB 6290ms 240ms truffleruby 22.3.1
ruby 1.rb 4125ms 19ms 53.7MB 4087ms 23ms ruby/yjit 3.2.0
ruby 1.rb 4936ms 27ms 52.7MB 4890ms 23ms ruby 3.2.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1n.kt 548ms 2.0ms 1.5MB 537ms 0ms kotlin/native 1.8.0
kotlin 1.kt 573ms 6.6ms 42.9MB 570ms 13ms kotlin/jvm 17.0.2
ruby 2.rb 1036ms 17ms 305.8MB 1233ms 93ms truffleruby 22.3.1
ruby 2.rb timeout 0.0ms 32.1MB 4977ms 7ms ruby 3.2.0
ruby 2.rb timeout 0.0ms 33.0MB 4973ms 10ms ruby/yjit 3.2.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1n.kt 58ms 1.5ms 1.5MB 47ms 0ms kotlin/native 1.8.0
kotlin 1.kt 140ms 5.3ms 42.7MB 140ms 17ms kotlin/jvm 17.0.2
ruby 2-m.rb 471ms 46ms 316.8MB 680ms 137ms truffleruby 22.3.1
ruby 2.rb 2176ms 4.7ms 33.0MB 2153ms 7ms ruby/yjit 3.2.0
ruby 2.rb 3381ms 35ms 32.3MB 3360ms 3ms ruby 3.2.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt timeout 0.0ms 218.2MB 5383ms 67ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 23.1MB 6287ms 170ms kotlin/native 1.8.0
kotlin 2n.kt timeout 0.0ms 10.4MB 5020ms 103ms kotlin/native 1.8.0
ruby 1.rb timeout 0.0ms 157.9MB 4937ms 47ms ruby 3.2.0
ruby 1.rb timeout 0.0ms 159.9MB 4923ms 53ms ruby/yjit 3.2.0
ruby 1.rb timeout 0.0ms 461.5MB 9333ms 257ms truffleruby 22.3.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 1437ms 6.9ms 210.3MB 1770ms 57ms kotlin/jvm 17.0.2
ruby 1-m.rb 2020ms 26ms 435.4MB 3657ms 173ms truffleruby 22.3.1
ruby 1.rb 2424ms 8.0ms 158.0MB 2343ms 63ms ruby 3.2.0
ruby 1.rb 2426ms 8.8ms 159.8MB 2343ms 67ms ruby/yjit 3.2.0
kotlin 1n.kt timeout 0.0ms 18.8MB 6257ms 147ms kotlin/native 1.8.0
kotlin 2n.kt timeout 0.0ms 10.2MB 5017ms 103ms kotlin/native 1.8.0

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt timeout 0.0ms 159.4MB 5310ms 60ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 277.3MB 5447ms 763ms kotlin/native 1.8.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 1080ms 5.7ms 95.1MB 1430ms 33ms kotlin/jvm 17.0.2
kotlin 1n.kt 4415ms 48ms 65.1MB 5760ms 13ms kotlin/native 1.8.0

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 4451ms 34ms 184.1MB 5353ms 50ms kotlin/jvm 17.0.2

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1-m.kt 1374ms 19ms 184.2MB 2113ms 47ms kotlin/jvm 17.0.2