Kotlin VS Rust benchmarks

Current benchmark data was generated on Sun Jun 01 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 507ms 12ms 574.5MB 603ms 97ms kotlin/jvm 21
rust 4.rs 1263ms 18ms 33.6MB 1243ms 3ms rustc 1.87.0
rust 5.rs 1337ms 12ms 33.8MB 1313ms 7ms rustc 1.87.0
rust 3.rs 1434ms 36ms 49.8MB 1403ms 17ms rustc 1.87.0
kotlin 1.kt 3832ms 23ms 145.7MB 4013ms 63ms kotlin/native 2.1.20

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4.rs 122ms 2.1ms 5.8MB 110ms 0ms rustc 1.87.0
kotlin 1.kt 124ms 1.0ms 159.2MB 150ms 27ms kotlin/jvm 21
rust 5.rs 125ms 2.8ms 5.8MB 113ms 0ms rustc 1.87.0
rust 3.rs 137ms 1.7ms 7.8MB 130ms 0ms rustc 1.87.0
kotlin 1.kt 208ms 3.8ms 17.6MB 217ms 0ms kotlin/native 2.1.20

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-m.rs 559ms 49ms 9.1MB 2110ms 60ms rustc 1.87.0
rust 5-m.rs 658ms 6.0ms 5.9MB 2497ms 63ms rustc 1.87.0
rust 1-m.rs 966ms 9.1ms 7.3MB 3573ms 223ms rustc 1.87.0
rust 3.rs 1139ms 7.2ms 9.3MB 1103ms 20ms rustc 1.87.0
kotlin 2-m.kt 1735ms 114ms 233.9MB 6417ms 103ms kotlin/jvm 21
rust 4.rs 1950ms 56ms 6.9MB 1937ms 0ms rustc 1.87.0
kotlin 1.kt 2195ms 28ms 218.9MB 3027ms 70ms kotlin/jvm 21
kotlin 2-m.kt 4274ms 24ms 21.4MB 14387ms 537ms kotlin/native 2.1.20
kotlin 1.kt timeout 0.0ms 17.4MB 5507ms 27ms kotlin/native 2.1.20

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5-m.rs 52ms 1.1ms 3.3MB 160ms 7ms rustc 1.87.0
rust 3-m.rs 54ms 7.6ms 4.3MB 170ms 10ms rustc 1.87.0
rust 3.rs 72ms 2.6ms 4.0MB 60ms 0ms rustc 1.87.0
rust 1-m.rs 75ms 0.8ms 3.6MB 240ms 20ms rustc 1.87.0
rust 4.rs 119ms 4.2ms 3.1MB 113ms 0ms rustc 1.87.0
kotlin 2-m.kt 249ms 1.7ms 21.5MB 843ms 37ms kotlin/native 2.1.20
kotlin 1.kt 386ms 5.8ms 17.4MB 400ms 0ms kotlin/native 2.1.20
kotlin 1-m.kt 474ms 14ms 73.5MB 1073ms 43ms kotlin/jvm 21
kotlin 2-m.kt 923ms 20ms 101.3MB 3240ms 73ms kotlin/jvm 21

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 1.2ms 0.0ms 1.8MB 0ms 0ms rustc 1.87.0
rust 1.rs 1.4ms 0.2ms 1.8MB 0ms 0ms rustc 1.89.0-nightly
kotlin 1.kt 2.2ms 0.1ms 3.1MB 0ms 0ms kotlin/native 2.1.20
kotlin 1.kt 62ms 0.6ms 47.7MB 74ms 16ms kotlin/jvm 21

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1-m.rs 284ms 67ms 73.3MB 163ms 437ms rustc 1.87.0
rust 2-http2.rs 345ms 19ms 53.5MB 813ms 367ms rustc 1.87.0
rust 2-m.rs 418ms 86ms 65.8MB 213ms 777ms rustc 1.87.0
rust 1-http2.rs 491ms 205ms 68.1MB 1267ms 467ms rustc 1.87.0
kotlin 2-m.kt 4825ms 117ms 434.8MB 15097ms 2490ms kotlin/jvm 21
kotlin 1.kt timeout 0.0ms 434.8MB 16347ms 2720ms kotlin/jvm 21

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1-m.rs 43ms 3.0ms 17.5MB 20ms 60ms rustc 1.87.0
rust 2-m.rs 83ms 4.6ms 22.9MB 30ms 167ms rustc 1.87.0
rust 1-http2.rs 209ms 59ms 26.9MB 540ms 187ms rustc 1.87.0
rust 2-http2.rs 247ms 14ms 27.1MB 687ms 183ms rustc 1.87.0
kotlin 2-m.kt 2078ms 157ms 233.3MB 5667ms 590ms kotlin/jvm 21
kotlin 1-m.kt 2112ms 39ms 272.7MB 5717ms 583ms kotlin/jvm 21

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5-i.rs 29ms 1.8ms 9.8MB 20ms 0ms rustc 1.87.0
rust 4-i.rs 31ms 0.8ms 7.9MB 20ms 0ms rustc 1.87.0
rust 2.rs 59ms 2.6ms 33.8MB 37ms 10ms rustc 1.87.0
rust 3.rs 59ms 2.5ms 32.0MB 37ms 7ms rustc 1.87.0
rust 1.rs 99ms 3.4ms 67.4MB 63ms 23ms rustc 1.87.0
kotlin 1-m.kt 732ms 78ms 157.5MB 1977ms 67ms kotlin/jvm 21

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5-i.rs 217ms 2.8ms 53.3MB 190ms 10ms rustc 1.87.0
rust 4-i.rs 259ms 4.8ms 54.5MB 207ms 40ms rustc 1.87.0
rust 2.rs 389ms 5.3ms 238.3MB 283ms 93ms rustc 1.87.0
rust 3.rs 406ms 4.6ms 237.8MB 303ms 90ms rustc 1.87.0
rust 1.rs 684ms 5.4ms 551.8MB 440ms 233ms rustc 1.87.0
kotlin 1-m.kt 1846ms 49ms 711.3MB 4333ms 173ms kotlin/jvm 21

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 37ms 4.5ms 1.9MB 27ms 0ms rustc 1.87.0
rust 1.rs 45ms 1.9ms 1.9MB 40ms 0ms rustc 1.87.0
kotlin 2.kt 166ms 3.8ms 12.4MB 170ms 0ms kotlin/native 2.1.20
kotlin 1-m.kt 195ms 3.4ms 95.1MB 327ms 27ms kotlin/jvm 21
kotlin 2-m.kt 200ms 3.1ms 102.1MB 437ms 40ms kotlin/jvm 21
kotlin 1.kt 355ms 2.4ms 12.4MB 353ms 3ms kotlin/native 2.1.20

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 144ms 3.7ms 1.8MB 133ms 0ms rustc 1.87.0
rust 1.rs 212ms 30ms 1.9MB 200ms 0ms rustc 1.87.0
kotlin 2-m.kt 317ms 3.3ms 213.3MB 553ms 43ms kotlin/jvm 21
kotlin 1.kt 340ms 3.7ms 203.0MB 463ms 37ms kotlin/jvm 21
kotlin 2.kt 474ms 2.5ms 12.4MB 500ms 0ms kotlin/native 2.1.20
kotlin 1.kt 1041ms 16ms 12.5MB 1067ms 3ms kotlin/native 2.1.20

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 23ms 0.6ms 1.8MB 13ms 0ms rustc 1.87.0
rust 1.rs 29ms 0.6ms 1.8MB 20ms 0ms rustc 1.87.0
kotlin 2.kt 94ms 0.9ms 12.8MB 83ms 0ms kotlin/native 2.1.20
kotlin 1.kt 120ms 0.5ms 12.8MB 110ms 3ms kotlin/native 2.1.20
kotlin 1-m.kt 153ms 0.0ms 90.8MB 303ms 23ms kotlin/jvm 21
kotlin 2-m.kt 161ms 4.6ms 96.1MB 343ms 30ms kotlin/jvm 21

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 384ms 3.9ms 680.1MB 450ms 87ms kotlin/jvm 21
rust 1.rs 690ms 2.4ms 33.8MB 667ms 7ms rustc 1.87.0
kotlin 1.kt 1811ms 15ms 89.9MB 1887ms 43ms kotlin/native 2.1.20

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 152ms 5.9ms 9.8MB 143ms 0ms rustc 1.87.0
kotlin 1-m.kt 158ms 4.9ms 207.2MB 210ms 43ms kotlin/jvm 21
kotlin 1.kt 255ms 3.0ms 25.3MB 260ms 10ms kotlin/native 2.1.20

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 164ms 0.4ms 1.8MB 157ms 0ms rustc 1.87.0
rust 7-i.rs 217ms 0.1ms 1.8MB 210ms 0ms rustc 1.87.0
rust 1.rs 229ms 0.8ms 1.8MB 220ms 0ms rustc 1.87.0
rust 3.rs 279ms 0.8ms 1.8MB 270ms 0ms rustc 1.89.0-nightly
rust 2.rs 279ms 0.6ms 1.6MB 270ms 0ms rustc 1.87.0
kotlin 1n.kt 349ms 0.4ms 3.5MB 340ms 0ms kotlin/native 2.1.20
kotlin 1.kt 446ms 2.7ms 49.3MB 490ms 20ms kotlin/jvm 21

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 18ms 0.1ms 1.8MB 10ms 0ms rustc 1.87.0
rust 7-i.rs 24ms 0.5ms 1.8MB 20ms 0ms rustc 1.87.0
rust 1.rs 25ms 0.4ms 1.8MB 20ms 0ms rustc 1.87.0
rust 3.rs 30ms 0.1ms 1.8MB 20ms 0ms rustc 1.89.0-nightly
rust 2.rs 30ms 0.2ms 1.6MB 20ms 0ms rustc 1.87.0
kotlin 1n.kt 38ms 0.7ms 3.5MB 30ms 0ms kotlin/native 2.1.20
kotlin 1-m.kt 119ms 0.7ms 49.6MB 163ms 20ms kotlin/jvm 21

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 1517ms 14ms 2.7MB 1313ms 187ms rustc 1.87.0
rust 2.rs 1714ms 21ms 2.7MB 1633ms 67ms rustc 1.87.0
kotlin 1.kt 3710ms 30ms 353.2MB 4553ms 117ms kotlin/jvm 21
kotlin 1n.kt timeout 0.0ms 26.7MB 3983ms 1510ms kotlin/native 2.1.20
kotlin 2n.kt timeout 0.0ms 30.6MB 5117ms 133ms kotlin/native 2.1.20

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 319ms 4.3ms 2.4MB 290ms 13ms rustc 1.87.0
rust 2.rs 381ms 2.2ms 2.4MB 367ms 0ms rustc 1.87.0
kotlin 1-m.kt 975ms 38ms 365.7MB 1740ms 93ms kotlin/jvm 21
kotlin 1n.kt timeout 0.0ms 26.3MB 3980ms 1510ms kotlin/native 2.1.20
kotlin 2n.kt timeout 0.0ms 30.6MB 5123ms 113ms kotlin/native 2.1.20

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 7.rs 443ms 4.9ms 78.6MB 457ms 13ms rustc 1.87.0
kotlin 1.kt timeout 0.0ms 173.5MB 5413ms 47ms kotlin/jvm 21
kotlin 1n.kt timeout 0.0ms 226.9MB 5057ms 127ms kotlin/native 2.1.20

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 7.rs 50ms 1.8ms 11.6MB 40ms 0ms rustc 1.87.0
kotlin 1-m.kt 834ms 5.0ms 134.5MB 1307ms 40ms kotlin/jvm 21
kotlin 1n.kt 3338ms 285ms 51.2MB 3400ms 73ms kotlin/native 2.1.20

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0.rs 117ms 3.1ms 1.9MB 110ms 0ms rustc 1.87.0
rust 1.rs 1422ms 8.7ms 1.9MB 1410ms 0ms rustc 1.87.0
kotlin 1.kt 3058ms 62ms 231.8MB 4043ms 70ms kotlin/jvm 21

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0.rs 32ms 1.3ms 1.8MB 23ms 0ms rustc 1.87.0
rust 1.rs 359ms 1.5ms 1.9MB 350ms 0ms rustc 1.87.0
kotlin 1-m.kt 964ms 26ms 231.0MB 1823ms 60ms kotlin/jvm 21