Kotlin VS Ruby benchmarks

Current benchmark data was generated on Mon Oct 03 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
kotlin 1.kt 630ms 12ms 413.5MB 673ms 63ms kotlin/jvm 17.0.2
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
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
kotlin 1.kt 135ms 16ms 109.6MB 130ms 20ms kotlin/jvm 17.0.2
kotlin 1-m.kt 411ms 10ms 42.6MB 653ms 10ms kotlin/native 1.7.20
ruby 1-m.rb 895ms 44ms 398.0MB 1443ms 123ms truffleruby 22.2.0
ruby 1.rb 905ms 6.4ms 292.0MB 750ms 140ms ruby/yjit 3.1.2
ruby 1.rb 973ms 7.5ms 35.5MB 940ms 13ms ruby 3.1.2

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2-m.kt 2846ms 155ms 182.7MB 5393ms 60ms kotlin/jvm 17.0.2
kotlin 1.kt 2911ms 11ms 160.2MB 3757ms 57ms kotlin/jvm 17.0.2
ruby 1.rb 3004ms 31ms 336.7MB 2820ms 170ms ruby/yjit 3.1.2
ruby 1.rb 3497ms 38ms 80.1MB 3437ms 47ms ruby 3.1.2
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
kotlin 2-m.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
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 238ms 2.6ms 42.3MB 213ms 10ms ruby 3.1.2
ruby 1.rb 385ms 0.9ms 298.8MB 220ms 147ms ruby/yjit 3.1.2
kotlin 1-m.kt 717ms 12ms 95.9MB 1253ms 53ms kotlin/jvm 17.0.2
kotlin 2-m.kt 812ms 42ms 36.5MB 1453ms 13ms kotlin/native 1.7.20
kotlin 1.kt 1014ms 7.1ms 8.9MB 1157ms 7ms kotlin/native 1.7.20
kotlin 2-m.kt 1040ms 12ms 105.8MB 1903ms 43ms kotlin/jvm 17.0.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 3.0ms 0.8ms 1.2MB 0ms 0ms kotlin/native 1.7.20
ruby 1.rb 42ms 2.5ms 148.7MB 18ms 22ms truffleruby 22.2.0
kotlin 1.kt 66ms 4.9ms 41.0MB 46ms 16ms kotlin/jvm 17.0.2
ruby 1.rb 70ms 0.2ms 30.0MB 48ms 6ms ruby 3.1.2
ruby 1.rb 238ms 0.3ms 286.6MB 94ms 134ms ruby/yjit 3.1.2

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/jvm 17.0.2
kotlin 2.kt timeout 0.0ms 0.0MB 0ms 0ms 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 2349ms 42ms 198.8MB 3487ms 213ms kotlin/jvm 17.0.2
kotlin 1-m.kt 2488ms 222ms 191.8MB 3967ms 267ms 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 437ms 10.0ms 49.4MB 397ms 20ms ruby 3.1.2
ruby 1.rb 601ms 0.7ms 306.3MB 437ms 143ms ruby/yjit 3.1.2
kotlin 1-m.kt 1126ms 3.0ms 206.9MB 1927ms 73ms kotlin/jvm 17.0.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 3871ms 3.8ms 163.2MB 3773ms 80ms ruby 3.1.2
ruby 1.rb 4038ms 3.0ms 419.5MB 3827ms 193ms ruby/yjit 3.1.2
kotlin 1.kt 4215ms 162ms 1116.9MB 6017ms 270ms kotlin/jvm 17.0.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
kotlin 2-m.kt 219ms 2.9ms 113.0MB 323ms 23ms kotlin/jvm 17.0.2
kotlin 1.kt 235ms 1.6ms 109.5MB 293ms 17ms kotlin/jvm 17.0.2
kotlin 2-m.kt 441ms 4.2ms 42.4MB 730ms 3ms kotlin/native 1.7.20
ruby 1.rb 615ms 14ms 30.1MB 593ms 10ms ruby 3.1.2
ruby 1.rb 628ms 4.4ms 286.7MB 473ms 137ms ruby/yjit 3.1.2
ruby 1-m.rb 773ms 57ms 312.0MB 1127ms 97ms truffleruby 22.2.0
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 2.kt 365ms 2.6ms 129.5MB 467ms 30ms kotlin/jvm 17.0.2
kotlin 1.kt 454ms 1.4ms 138.4MB 503ms 30ms kotlin/jvm 17.0.2
kotlin 2-m.kt 1339ms 41ms 147.6MB 2167ms 47ms kotlin/native 1.7.20
ruby 1.rb 1391ms 9.5ms 286.8MB 1243ms 130ms ruby/yjit 3.1.2
ruby 1.rb 1431ms 73ms 353.1MB 1917ms 123ms truffleruby 22.2.0
ruby 1.rb 1660ms 16ms 30.2MB 1640ms 7ms ruby 3.1.2
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1-m.kt 170ms 0.3ms 75.9MB 247ms 13ms kotlin/jvm 17.0.2
kotlin 2-m.kt 183ms 3.1ms 78.7MB 253ms 27ms kotlin/jvm 17.0.2
kotlin 2-m.kt 229ms 0.3ms 30.3MB 383ms 7ms kotlin/native 1.7.20
ruby 1.rb 337ms 2.5ms 29.9MB 317ms 7ms ruby 3.1.2
ruby 1.rb 433ms 1.4ms 286.6MB 270ms 140ms ruby/yjit 3.1.2
ruby 1-m.rb 568ms 48ms 298.6MB 857ms 90ms truffleruby 22.2.0
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 476ms 22ms 560.5MB 433ms 100ms kotlin/jvm 17.0.2
kotlin 1.kt 2306ms 14ms 138.6MB 3403ms 13ms kotlin/native 1.7.20
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
kotlin 1.kt 178ms 3.8ms 221.1MB 160ms 47ms kotlin/jvm 17.0.2
kotlin 1.kt 454ms 22ms 38.7MB 653ms 0ms kotlin/native 1.7.20
ruby 1-m.rb 3172ms 18ms 560.6MB 5827ms 207ms truffleruby 22.2.0
ruby 1.rb 3949ms 15ms 300.8MB 3790ms 140ms ruby/yjit 3.1.2
ruby 1.rb 4772ms 16ms 44.3MB 4743ms 13ms ruby 3.1.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 566ms 1.6ms 42.9MB 580ms 13ms kotlin/jvm 17.0.2
kotlin 1n.kt 577ms 55ms 1.2MB 567ms 0ms kotlin/native 1.7.20
ruby 2.rb 1111ms 6.0ms 308.1MB 1390ms 97ms 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
kotlin 1n.kt 58ms 0.3ms 1.2MB 50ms 0ms kotlin/native 1.7.20
kotlin 1.kt 136ms 0.9ms 43.1MB 150ms 7ms kotlin/jvm 17.0.2
ruby 2-m.rb 423ms 4.0ms 302.6MB 670ms 80ms truffleruby 22.2.0
ruby 2.rb 2352ms 4.8ms 286.8MB 2207ms 127ms ruby/yjit 3.1.2
ruby 2.rb 3223ms 7.6ms 29.9MB 3193ms 10ms ruby 3.1.2

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
kotlin 2n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
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
kotlin 1.kt 1459ms 42ms 205.9MB 1767ms 57ms kotlin/jvm 17.0.2
ruby 1-m.rb 1926ms 9.5ms 380.4MB 3533ms 143ms truffleruby 22.2.0
ruby 1.rb 2511ms 13ms 162.8MB 2427ms 63ms ruby 3.1.2
ruby 1.rb 2672ms 16ms 420.8MB 2457ms 203ms ruby/yjit 3.1.2
kotlin 1n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20
kotlin 2n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20

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 0.0MB 0ms 0ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 0.0MB 0ms 0ms kotlin/native 1.7.20

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 1070ms 13ms 95.0MB 1467ms 30ms kotlin/jvm 17.0.2
kotlin 1n.kt 4349ms 20ms 65.2MB 5673ms 17ms kotlin/native 1.7.20

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 4483ms 33ms 189.8MB 5407ms 53ms 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 1369ms 12ms 191.8MB 2107ms 50ms kotlin/jvm 17.0.2