Rust VS Kotlin benchmarks

Current benchmark data was generated on Mon Feb 06 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz (Model 85)

* -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.)

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5c-m.rs 177ms 2.2ms 1.7MB 310ms 0ms rustc 1.69.0-nightly
rust 5-m.rs 196ms 3.3ms 1.7MB 347ms 0ms rustc 1.67.0
rust 1c.rs 213ms 0.5ms 1.1MB 200ms 0ms rustc 1.69.0-nightly
rust 1.rs 272ms 8.0ms 1.0MB 260ms 0ms rustc 1.67.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1c.rs 25ms 0.5ms 1.0MB 17ms 0ms rustc 1.69.0-nightly
rust 5c-m.rs 29ms 1.4ms 1.7MB 27ms 0ms rustc 1.69.0-nightly
rust 1.rs 30ms 0.5ms 1.1MB 20ms 0ms rustc 1.67.0
rust 5-m.rs 31ms 0.8ms 1.8MB 40ms 0ms rustc 1.67.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 1.8ms 0.6ms 1.7MB 0ms 0ms rustc 1.69.0-nightly
rust 1.rs 2.4ms 0.7ms 1.0MB 0ms 0ms rustc 1.67.0
kotlin 1.kt 2.7ms 0.5ms 1.5MB 0ms 0ms kotlin/native 1.8.10
kotlin 1.kt 68ms 5.9ms 40.9MB 54ms 12ms kotlin/jvm 17.0.2

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 9.rs 360ms 0.4ms 4.6MB 347ms 0ms rustc 1.69.0-nightly
rust 8.rs 428ms 0.1ms 4.9MB 420ms 0ms rustc 1.67.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 9.rs 19ms 0.3ms 1.0MB 10ms 0ms rustc 1.69.0-nightly
rust 8.rs 20ms 0.1ms 1.0MB 10ms 0ms rustc 1.67.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 213ms 0.6ms 1.0MB 200ms 0ms rustc 1.67.0
rust 7-i.rs 310ms 0.5ms 1.1MB 300ms 0ms rustc 1.67.0
rust 2.rs 344ms 0.2ms 1.1MB 333ms 0ms rustc 1.67.0
rust 3.rs 347ms 1.3ms 1.1MB 330ms 0ms rustc 1.69.0-nightly
rust 1.rs 421ms 4.5ms 1.0MB 407ms 0ms rustc 1.67.0
kotlin 1.kt 660ms 1.7ms 43.2MB 647ms 23ms kotlin/jvm 17.0.2
kotlin 1n.kt 660ms 9.2ms 1.5MB 650ms 0ms kotlin/native 1.8.10

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 24ms 0.3ms 1.0MB 10ms 0ms rustc 1.67.0
rust 7-i.rs 34ms 0.3ms 1.1MB 23ms 0ms rustc 1.67.0
rust 2.rs 37ms 0.1ms 1.0MB 27ms 0ms rustc 1.67.0
rust 3.rs 37ms 0.2ms 1.1MB 30ms 0ms rustc 1.69.0-nightly
rust 1.rs 45ms 0.6ms 1.0MB 33ms 0ms rustc 1.67.0
kotlin 1n.kt 75ms 2.4ms 5.5MB 67ms 0ms kotlin/native 1.8.10
kotlin 1.kt 156ms 6.4ms 42.8MB 153ms 20ms kotlin/jvm 17.0.2

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 897ms 2.7ms 2.5MB 1733ms 0ms rustc 1.69.0-nightly
rust 7-m.rs 900ms 3.1ms 2.3MB 1733ms 3ms rustc 1.67.0
rust 8.rs 1724ms 0.3ms 2.4MB 1710ms 0ms rustc 1.69.0-nightly
rust 7.rs 1731ms 0.8ms 1.1MB 1717ms 0ms rustc 1.67.0
rust 2-m.rs 1827ms 1.5ms 2.3MB 3553ms 0ms rustc 1.67.0
rust 2.rs timeout 0.0ms 2.2MB 4987ms 0ms rustc 1.67.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 236ms 3.3ms 2.3MB 427ms 0ms rustc 1.69.0-nightly
rust 7-m.rs 238ms 2.4ms 1.0MB 430ms 0ms rustc 1.67.0
rust 8.rs 434ms 0.3ms 2.2MB 423ms 0ms rustc 1.69.0-nightly
rust 7.rs 436ms 0.4ms 1.1MB 427ms 0ms rustc 1.67.0
rust 2-m.rs 481ms 9.7ms 2.1MB 897ms 0ms rustc 1.67.0
rust 2.rs 1631ms 3.2ms 1.1MB 1620ms 0ms rustc 1.67.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 65ms 1.0ms 1.0MB 107ms 0ms rustc 1.69.0-nightly
rust 7-m.rs 66ms 2.1ms 1.1MB 103ms 0ms rustc 1.67.0
rust 8.rs 111ms 0.3ms 1.0MB 100ms 0ms rustc 1.69.0-nightly
rust 7.rs 111ms 0.4ms 1.8MB 100ms 0ms rustc 1.67.0
rust 2-m.rs 125ms 0.4ms 1.0MB 220ms 0ms rustc 1.67.0
rust 2.rs 410ms 0.4ms 1.0MB 400ms 0ms rustc 1.67.0

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 680ms 32ms 605.5MB 653ms 140ms kotlin/jvm 17.0.2
rust 4.rs 1746ms 19ms 33.8MB 1717ms 13ms rustc 1.67.0
rust 5.rs 1946ms 27ms 33.7MB 1917ms 13ms rustc 1.67.0
rust 3.rs 2082ms 16ms 49.9MB 2047ms 20ms rustc 1.67.0
kotlin 1.kt timeout 0.0ms 214.4MB 8197ms 1193ms kotlin/native 1.8.10

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 148ms 16ms 109.3MB 117ms 33ms kotlin/jvm 17.0.2
rust 4.rs 153ms 0.2ms 5.7MB 140ms 0ms rustc 1.67.0
rust 5.rs 168ms 0.6ms 5.8MB 160ms 0ms rustc 1.67.0
rust 3.rs 177ms 2.0ms 7.8MB 167ms 0ms rustc 1.67.0
kotlin 1-m.kt 596ms 9.2ms 30.5MB 1030ms 100ms kotlin/native 1.8.10

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-m.rs 1016ms 80ms 6.2MB 1933ms 33ms rustc 1.67.0
rust 5-m.rs 1190ms 249ms 4.3MB 2270ms 40ms rustc 1.67.0
rust 3.rs 2025ms 60ms 6.2MB 1983ms 27ms rustc 1.67.0
rust 4.rs 3020ms 14ms 4.4MB 3007ms 0ms rustc 1.67.0
kotlin 2-m.kt 3157ms 743ms 180.6MB 5957ms 97ms kotlin/jvm 17.0.2
kotlin 1.kt 3186ms 97ms 160.2MB 4060ms 70ms kotlin/jvm 17.0.2
rust 1-m.rs 3466ms 17ms 5.0MB 6697ms 97ms rustc 1.67.0
kotlin 1.kt timeout 0.0ms 10.7MB 6297ms 270ms kotlin/native 1.8.10
kotlin 2-m.kt timeout 0.0ms 31.8MB 9370ms 150ms kotlin/native 1.8.10

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-m.rs 98ms 17ms 2.8MB 140ms 3ms rustc 1.67.0
rust 3.rs 118ms 1.2ms 3.2MB 100ms 0ms rustc 1.67.0
rust 5-m.rs 119ms 15ms 2.6MB 197ms 10ms rustc 1.67.0
rust 4.rs 198ms 2.2ms 2.4MB 183ms 0ms rustc 1.67.0
rust 1-m.rs 232ms 0.0ms 2.8MB 413ms 17ms rustc 1.67.0
kotlin 1-m.kt 752ms 40ms 101.1MB 1307ms 60ms kotlin/jvm 17.0.2
kotlin 2-m.kt 1041ms 62ms 99.5MB 1863ms 50ms kotlin/jvm 17.0.2
kotlin 2-m.kt 1092ms 41ms 26.4MB 1957ms 43ms kotlin/native 1.8.10
kotlin 1.kt 1175ms 17ms 8.7MB 1417ms 97ms kotlin/native 1.8.10

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 138ms 1.1ms 3.6MB 123ms 0ms rustc 1.67.0
rust 2.rs 575ms 1.0ms 3.7MB 563ms 0ms rustc 1.67.0

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 39ms 0.3ms 2.9MB 30ms 0ms rustc 1.67.0
rust 2.rs 113ms 1.4ms 3.1MB 100ms 0ms rustc 1.67.0

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-im.rs 626ms 1.5ms 1.1MB 1210ms 0ms rustc 1.67.0
rust 2-im.rs 965ms 0.1ms 1.0MB 1847ms 0ms rustc 1.67.0
rust 5-m.rs 1189ms 1.8ms 1.0MB 2307ms 0ms rustc 1.67.0
rust 3-i.rs 1234ms 1.2ms 1.1MB 1223ms 0ms rustc 1.67.0
rust 2-i.rs 1833ms 1.3ms 1.0MB 1820ms 0ms rustc 1.67.0
rust 1-m.rs 2361ms 23ms 1.1MB 4583ms 0ms rustc 1.67.0
rust 1.rs 3906ms 24ms 1.1MB 3893ms 0ms rustc 1.67.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-im.rs 60ms 0.8ms 1.0MB 100ms 0ms rustc 1.67.0
rust 2-im.rs 87ms 1.7ms 1.0MB 147ms 0ms rustc 1.67.0
rust 3-i.rs 105ms 0.3ms 1.0MB 97ms 0ms rustc 1.67.0
rust 5-m.rs 110ms 4.7ms 1.0MB 183ms 0ms rustc 1.67.0
rust 2-i.rs 156ms 0.9ms 1.0MB 147ms 0ms rustc 1.67.0
rust 1-m.rs 211ms 0.5ms 1.0MB 380ms 0ms rustc 1.67.0
rust 1.rs 328ms 1.7ms 1.0MB 313ms 0ms rustc 1.67.0

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 137ms 24ms 20.8MB 60ms 100ms rustc 1.67.0
rust 2-http2.rs 302ms 40ms 33.4MB 407ms 90ms rustc 1.67.0
rust 2-m.rs 581ms 13ms 103.2MB 297ms 597ms rustc 1.67.0
rust 1-http2.rs 1017ms 139ms 74.1MB 1243ms 530ms rustc 1.67.0
kotlin 1.kt timeout 0.0ms 240.0MB 8973ms 560ms kotlin/jvm 17.0.2
kotlin 2.kt timeout 0.0ms 296.4MB 8620ms 767ms kotlin/jvm 17.0.2

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 77ms 22ms 18.9MB 17ms 33ms rustc 1.67.0
rust 2.rs 140ms 11ms 24.4MB 57ms 87ms rustc 1.67.0
rust 1-http2.rs 312ms 54ms 26.8MB 383ms 117ms rustc 1.67.0
rust 2-http2.rs 393ms 7.3ms 25.6MB 540ms 127ms rustc 1.67.0
kotlin 2-m.kt 2762ms 277ms 199.6MB 4230ms 370ms kotlin/jvm 17.0.2
kotlin 1-m.kt 3108ms 353ms 192.5MB 4943ms 437ms kotlin/jvm 17.0.2

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 2.rs 80ms 0.2ms 38.1MB 57ms 7ms rustc 1.67.0
rust 3.rs 83ms 1.8ms 36.3MB 53ms 13ms rustc 1.67.0
rust 1.rs 146ms 8.2ms 75.5MB 87ms 43ms rustc 1.67.0
kotlin 1-m.kt 1233ms 3.7ms 216.0MB 2020ms 103ms kotlin/jvm 17.0.2

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 2.rs 505ms 1.3ms 257.9MB 367ms 117ms rustc 1.67.0
rust 3.rs 519ms 1.0ms 258.7MB 390ms 113ms rustc 1.67.0
rust 1.rs 926ms 1.8ms 605.6MB 653ms 257ms rustc 1.67.0
kotlin 1.kt 4641ms 52ms 858.7MB 6480ms 293ms kotlin/jvm 17.0.2

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 470ms 114ms 30.1MB 693ms 10ms rustc 1.67.0
rust 8.rs 646ms 17ms 24.1MB 627ms 10ms rustc 1.67.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 52ms 3.2ms 16.5MB 73ms 0ms rustc 1.67.0
rust 8.rs 81ms 2.0ms 11.6MB 63ms 3ms rustc 1.67.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 58ms 2.0ms 1.1MB 50ms 0ms rustc 1.67.0
rust 1.rs 74ms 0.5ms 1.0MB 63ms 0ms rustc 1.67.0
kotlin 2.kt 253ms 4.6ms 113.5MB 353ms 23ms kotlin/jvm 17.0.2
kotlin 1.kt 271ms 20ms 113.4MB 323ms 43ms kotlin/jvm 17.0.2
kotlin 2-m.kt 468ms 3.6ms 48.2MB 687ms 23ms kotlin/native 1.8.10
kotlin 1.kt timeout 0.0ms 14.9MB 5003ms 7ms kotlin/native 1.8.10

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 195ms 7.8ms 1.0MB 180ms 0ms rustc 1.67.0
rust 1.rs 296ms 0.9ms 1.0MB 283ms 0ms rustc 1.67.0
kotlin 2.kt 423ms 8.2ms 125.2MB 493ms 50ms kotlin/jvm 17.0.2
kotlin 1.kt 490ms 5.2ms 132.5MB 530ms 37ms kotlin/jvm 17.0.2
kotlin 2.kt 1471ms 4.0ms 115.4MB 2097ms 90ms kotlin/native 1.8.10
kotlin 1.kt timeout 0.0ms 17.3MB 4993ms 13ms kotlin/native 1.8.10

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 33ms 1.1ms 1.7MB 20ms 0ms rustc 1.67.0
rust 1.rs 48ms 0.4ms 1.1MB 40ms 0ms rustc 1.67.0
kotlin 1.kt 190ms 6.1ms 73.7MB 247ms 23ms kotlin/jvm 17.0.2
kotlin 2-m.kt 198ms 6.4ms 75.8MB 280ms 20ms kotlin/jvm 17.0.2
kotlin 2-m.kt 232ms 1.0ms 28.3MB 357ms 7ms kotlin/native 1.8.10
kotlin 1.kt timeout 0.0ms 17.1MB 5000ms 7ms kotlin/native 1.8.10

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
kotlin 1.kt 514ms 21ms 361.1MB 490ms 93ms kotlin/jvm 17.0.2
rust 1.rs 949ms 11ms 34.0MB 920ms 13ms rustc 1.67.0
kotlin 1-m.kt 3231ms 169ms 138.5MB 4950ms 777ms kotlin/native 1.8.10

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 192ms 1.1ms 9.9MB 180ms 0ms rustc 1.67.0
kotlin 1.kt 203ms 3.9ms 221.1MB 177ms 57ms kotlin/jvm 17.0.2
kotlin 1-m.kt 648ms 0.2ms 38.4MB 1067ms 100ms kotlin/native 1.8.10

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 2.rs 460ms 4.8ms 6.6MB 443ms 3ms rustc 1.67.0
rust 1.rs 1406ms 28ms 40.7MB 1373ms 17ms rustc 1.67.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 2.rs 102ms 1.2ms 3.1MB 90ms 0ms rustc 1.67.0
rust 1.rs 167ms 15ms 11.6MB 150ms 0ms rustc 1.67.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 2.rs 1651ms 1.0ms 2.8MB 1583ms 47ms rustc 1.67.0
rust 1.rs 1705ms 3.0ms 2.8MB 1520ms 170ms rustc 1.67.0
kotlin 1.kt timeout 0.0ms 212.7MB 5380ms 73ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 18.8MB 6640ms 163ms kotlin/native 1.8.10
kotlin 2n.kt timeout 0.0ms 11.0MB 5047ms 123ms kotlin/native 1.8.10

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 368ms 1.1ms 2.5MB 350ms 7ms rustc 1.67.0
rust 2.rs 374ms 0.9ms 2.6MB 360ms 0ms rustc 1.67.0
kotlin 1.kt 1500ms 20ms 248.1MB 1817ms 97ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 19.0MB 6643ms 180ms kotlin/native 1.8.10
kotlin 2n.kt timeout 0.0ms 8.2MB 5037ms 130ms kotlin/native 1.8.10

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 7.rs 568ms 7.4ms 77.6MB 733ms 17ms rustc 1.67.0
kotlin 1.kt timeout 0.0ms 161.4MB 5330ms 63ms kotlin/jvm 17.0.2
kotlin 1n.kt timeout 0.0ms 277.2MB 5207ms 970ms kotlin/native 1.8.10

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 7.rs 65ms 1.4ms 11.6MB 67ms 3ms rustc 1.67.0
kotlin 1.kt 1024ms 13ms 95.3MB 1387ms 47ms kotlin/jvm 17.0.2
kotlin 1n.kt 4777ms 65ms 65.3MB 6153ms 33ms kotlin/native 1.8.10

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0.rs 137ms 0.2ms 1.1MB 130ms 0ms rustc 1.67.0
rust 1.rs 1900ms 67ms 1.0MB 1890ms 0ms rustc 1.67.0
kotlin 1.kt 4515ms 7.7ms 187.0MB 5427ms 73ms kotlin/jvm 17.0.2

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0.rs 37ms 0.4ms 1.0MB 27ms 0ms rustc 1.67.0
rust 1.rs 466ms 0.4ms 1.1MB 453ms 0ms rustc 1.67.0
kotlin 1-m.kt 1387ms 15ms 186.2MB 2147ms 67ms kotlin/jvm 17.0.2