Kotlin VS Rust 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
rust 4.rs 1281ms 5.2ms 33.6MB 1260ms 7ms rustc 1.86.0
rust 5.rs 1344ms 1.4ms 33.8MB 1317ms 10ms rustc 1.86.0
rust 3.rs 1480ms 48ms 49.8MB 1450ms 13ms rustc 1.86.0
kotlin 1.kt 4515ms 38ms 146.1MB 4703ms 67ms kotlin/native 2.1.20

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4.rs 123ms 2.7ms 5.6MB 117ms 0ms rustc 1.86.0
kotlin 1.kt 126ms 1.8ms 161.2MB 150ms 37ms kotlin/jvm 21
rust 5.rs 127ms 1.9ms 5.8MB 120ms 0ms rustc 1.86.0
rust 3.rs 143ms 9.2ms 7.8MB 130ms 0ms rustc 1.86.0
kotlin 1.kt 318ms 32ms 17.9MB 327ms 7ms 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 550ms 46ms 9.1MB 2070ms 70ms rustc 1.86.0
rust 5-m.rs 667ms 6.9ms 5.6MB 2517ms 67ms rustc 1.86.0
rust 1-m.rs 937ms 11ms 8.5MB 3437ms 210ms rustc 1.86.0
rust 3.rs 1112ms 2.4ms 9.3MB 1070ms 30ms rustc 1.86.0
rust 4.rs 1884ms 5.6ms 7.4MB 1867ms 0ms rustc 1.86.0
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

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5-m.rs 53ms 2.0ms 3.4MB 157ms 13ms rustc 1.86.0
rust 3-m.rs 57ms 2.2ms 4.3MB 180ms 10ms rustc 1.86.0
rust 3.rs 71ms 2.9ms 4.0MB 60ms 0ms rustc 1.86.0
rust 1-m.rs 72ms 0.7ms 3.8MB 227ms 23ms rustc 1.86.0
rust 4.rs 115ms 0.3ms 3.3MB 107ms 0ms rustc 1.86.0
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

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 1.2ms 0.1ms 1.9MB 0ms 0ms rustc 1.86.0
rust 1.rs 1.2ms 0.1ms 1.8MB 0ms 0ms rustc 1.88.0-nightly
kotlin 1.kt 2.1ms 0.1ms 3.1MB 0ms 0ms kotlin/native 2.1.20
kotlin 1.kt 67ms 2.3ms 47.7MB 82ms 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 306ms 70ms 84.5MB 163ms 513ms rustc 1.86.0
rust 2-m.rs 412ms 81ms 69.0MB 237ms 887ms rustc 1.86.0
rust 2-http2.rs 422ms 21ms 60.3MB 873ms 543ms rustc 1.86.0
rust 1-http2.rs 623ms 77ms 63.6MB 1497ms 697ms rustc 1.86.0
kotlin 1.kt timeout 0.0ms 405.5MB 16143ms 2733ms kotlin/jvm 21
kotlin 2.kt timeout 0.0ms 458.9MB 15747ms 2687ms kotlin/jvm 21

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1-m.rs 43ms 6.4ms 17.5MB 17ms 60ms rustc 1.86.0
rust 2-m.rs 78ms 6.8ms 21.8MB 30ms 157ms rustc 1.86.0
rust 2-http2.rs 220ms 47ms 27.6MB 560ms 183ms rustc 1.86.0
rust 1-http2.rs 253ms 35ms 27.8MB 683ms 197ms rustc 1.86.0
kotlin 1-m.kt 2223ms 205ms 254.3MB 6403ms 687ms kotlin/jvm 21
kotlin 2-m.kt 2233ms 250ms 249.5MB 6100ms 650ms 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 28ms 1.1ms 9.8MB 20ms 0ms rustc 1.86.0
rust 4-i.rs 31ms 1.0ms 7.9MB 20ms 0ms rustc 1.86.0
rust 3.rs 62ms 0.9ms 32.0MB 40ms 10ms rustc 1.86.0
rust 2.rs 63ms 1.1ms 33.8MB 40ms 10ms rustc 1.86.0
rust 1.rs 100ms 1.6ms 67.4MB 63ms 23ms rustc 1.86.0
kotlin 1-m.kt 773ms 88ms 172.2MB 2063ms 87ms kotlin/jvm 21

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5-i.rs 209ms 2.5ms 52.6MB 183ms 13ms rustc 1.86.0
rust 4-i.rs 259ms 0.4ms 54.3MB 203ms 40ms rustc 1.86.0
rust 2.rs 409ms 4.6ms 237.6MB 307ms 90ms rustc 1.86.0
rust 3.rs 412ms 1.3ms 237.6MB 307ms 90ms rustc 1.86.0
rust 1.rs 686ms 5.4ms 550.2MB 447ms 227ms rustc 1.86.0
kotlin 1-m.kt 1862ms 58ms 671.6MB 4417ms 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 34ms 5.9ms 1.8MB 23ms 0ms rustc 1.86.0
rust 1.rs 57ms 5.3ms 1.9MB 47ms 0ms rustc 1.86.0
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
kotlin 1.kt 357ms 2.2ms 12.5MB 363ms 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 135ms 6.2ms 1.8MB 123ms 0ms rustc 1.86.0
rust 1.rs 199ms 28ms 1.9MB 190ms 0ms rustc 1.86.0
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
kotlin 1.kt 1043ms 15ms 12.6MB 1080ms 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.4ms 1.8MB 17ms 0ms rustc 1.86.0
rust 1.rs 30ms 2.2ms 1.8MB 23ms 0ms rustc 1.86.0
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

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
rust 1.rs 703ms 1.4ms 33.8MB 680ms 10ms rustc 1.86.0
kotlin 1.kt 2170ms 19ms 88.8MB 2273ms 40ms kotlin/native 2.1.20

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 150ms 2.2ms 9.8MB 140ms 0ms rustc 1.86.0
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

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 163ms 0.5ms 1.8MB 160ms 0ms rustc 1.86.0
rust 7-i.rs 237ms 0.9ms 1.8MB 230ms 0ms rustc 1.86.0
rust 1.rs 240ms 0.4ms 1.8MB 230ms 0ms rustc 1.86.0
rust 3.rs 279ms 0.7ms 1.9MB 270ms 0ms rustc 1.88.0-nightly
rust 2.rs 284ms 0.8ms 1.8MB 273ms 0ms rustc 1.86.0
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

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.86.0
rust 7-i.rs 26ms 0.5ms 1.9MB 20ms 0ms rustc 1.86.0
rust 1.rs 26ms 0.2ms 1.8MB 20ms 0ms rustc 1.86.0
rust 3.rs 30ms 0.1ms 1.8MB 20ms 0ms rustc 1.88.0-nightly
rust 2.rs 31ms 0.2ms 1.8MB 20ms 0ms rustc 1.86.0
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

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 1514ms 7.3ms 2.7MB 1303ms 197ms rustc 1.86.0
rust 2.rs 1711ms 4.7ms 2.7MB 1623ms 70ms rustc 1.86.0
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

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 320ms 0.7ms 2.4MB 293ms 13ms rustc 1.86.0
rust 2.rs 387ms 2.7ms 2.4MB 377ms 0ms rustc 1.86.0
kotlin 1-m.kt 992ms 27ms 355.5MB 1823ms 100ms kotlin/jvm 21
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

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 7.rs 439ms 6.7ms 77.6MB 457ms 13ms rustc 1.86.0
kotlin 1.kt timeout 0.0ms 173.6MB 5427ms 47ms kotlin/jvm 21
kotlin 1n.kt timeout 0.0ms 226.8MB 5100ms 123ms 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 48ms 0.7ms 12.6MB 40ms 0ms rustc 1.86.0
kotlin 1-m.kt 856ms 18ms 134.4MB 1317ms 43ms kotlin/jvm 21
kotlin 1n.kt 3255ms 36ms 51.1MB 3353ms 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 116ms 0.4ms 1.6MB 110ms 0ms rustc 1.86.0
rust 1.rs 1477ms 11ms 1.9MB 1470ms 0ms rustc 1.86.0
kotlin 1.kt 3093ms 47ms 230.3MB 3913ms 63ms kotlin/jvm 21

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0.rs 31ms 0.1ms 1.8MB 20ms 0ms rustc 1.86.0
rust 1.rs 366ms 0.8ms 1.9MB 360ms 0ms rustc 1.86.0
kotlin 1-m.kt 1029ms 38ms 233.4MB 1937ms 63ms kotlin/jvm 21