Rust VS Nim benchmarks

Current benchmark data was generated on Tue Apr 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.)

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 1.0ms 0.1ms 1.6MB 0ms 0ms nim 2.2.2
nim 1.nim 1.2ms 0.0ms 1.9MB 0ms 0ms nim/clang 2.2.2
rust 1.rs 1.3ms 0.0ms 1.8MB 0ms 0ms rustc 1.85.1
rust 1.rs 1.4ms 0.1ms 1.8MB 0ms 0ms rustc 1.88.0-nightly

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 9.rs 248ms 2.0ms 4.8MB 240ms 0ms rustc 1.88.0-nightly
rust 8.rs 308ms 0.6ms 4.8MB 300ms 0ms rustc 1.85.1
nim 1.nim 389ms 0.8ms 4.7MB 380ms 0ms nim/clang 2.2.2
nim 1.nim 578ms 2.6ms 4.4MB 570ms 0ms nim 2.2.2

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 9.rs 14ms 1.4ms 1.8MB 10ms 0ms rustc 1.88.0-nightly
rust 8.rs 15ms 0.2ms 1.9MB 10ms 0ms rustc 1.85.1
nim 1.nim 19ms 0.2ms 1.9MB 10ms 0ms nim/clang 2.2.2
nim 1.nim 29ms 2.3ms 1.6MB 20ms 0ms nim 2.2.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 165ms 3.6ms 1.9MB 157ms 0ms rustc 1.85.1
rust 7-i.rs 237ms 0.6ms 1.8MB 230ms 0ms rustc 1.85.1
rust 1.rs 240ms 0.7ms 1.8MB 230ms 0ms rustc 1.85.1
rust 3.rs 279ms 0.5ms 1.8MB 270ms 0ms rustc 1.88.0-nightly
rust 2.rs 279ms 0.8ms 1.8MB 270ms 0ms rustc 1.85.1
nim 2.nim 321ms 1.3ms 1.8MB 310ms 0ms nim 2.2.2
nim 2.nim 342ms 1.8ms 2.0MB 333ms 0ms nim/clang 2.2.2

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 18ms 0.1ms 1.9MB 10ms 0ms rustc 1.85.1
rust 7-i.rs 26ms 0.5ms 1.9MB 20ms 0ms rustc 1.85.1
rust 1.rs 26ms 0.4ms 1.9MB 20ms 0ms rustc 1.85.1
rust 3.rs 30ms 0.0ms 1.8MB 20ms 0ms rustc 1.88.0-nightly
rust 2.rs 30ms 0.8ms 1.8MB 20ms 0ms rustc 1.85.1
nim 2.nim 34ms 0.6ms 1.8MB 30ms 0ms nim 2.2.2
nim 2.nim 38ms 0.7ms 2.0MB 30ms 0ms nim/clang 2.2.2

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 494ms 0.5ms 2.6MB 1913ms 0ms rustc 1.88.0-nightly
rust 7-m.rs 501ms 0.3ms 2.3MB 1940ms 3ms rustc 1.85.1
rust 8.rs 996ms 1.9ms 2.5MB 987ms 0ms rustc 1.88.0-nightly
rust 2-m.rs 1955ms 1.5ms 2.4MB 7683ms 10ms rustc 1.85.1
rust 7.rs 2107ms 4.3ms 2.0MB 2100ms 0ms rustc 1.85.1
nim 1.nim 3591ms 2.6ms 1.6MB 3580ms 0ms nim/clang 2.2.2
nim 1.nim 3601ms 1.6ms 1.4MB 3590ms 0ms nim 2.2.2
rust 2.rs 4218ms 10.0ms 2.0MB 4207ms 0ms rustc 1.85.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 128ms 0.2ms 2.4MB 470ms 0ms rustc 1.88.0-nightly
rust 7-m.rs 131ms 1.8ms 2.1MB 477ms 0ms rustc 1.85.1
rust 8.rs 251ms 2.0ms 2.1MB 240ms 0ms rustc 1.88.0-nightly
rust 2-m.rs 493ms 0.3ms 2.1MB 1907ms 0ms rustc 1.85.1
rust 7.rs 531ms 2.8ms 1.8MB 520ms 0ms rustc 1.85.1
nim 1.nim 901ms 1.4ms 1.8MB 890ms 0ms nim 2.2.2
nim 1.nim 905ms 9.6ms 1.5MB 897ms 0ms nim/clang 2.2.2
rust 2.rs 1054ms 2.3ms 1.9MB 1043ms 0ms rustc 1.85.1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 35ms 0.1ms 2.1MB 107ms 3ms rustc 1.88.0-nightly
rust 7-m.rs 36ms 0.2ms 2.1MB 110ms 0ms rustc 1.85.1
rust 8.rs 64ms 0.0ms 2.0MB 60ms 0ms rustc 1.88.0-nightly
rust 2-m.rs 127ms 0.2ms 2.1MB 467ms 3ms rustc 1.85.1
rust 7.rs 138ms 1.1ms 1.9MB 130ms 0ms rustc 1.85.1
nim 1.nim 227ms 0.3ms 1.5MB 220ms 0ms nim/clang 2.2.2
nim 1.nim 229ms 1.8ms 1.3MB 220ms 0ms nim 2.2.2
rust 2.rs 266ms 1.3ms 1.9MB 260ms 0ms rustc 1.85.1

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 911ms 3.9ms 34.6MB 893ms 0ms nim 2.2.2
nim 2.nim 1032ms 45ms 34.9MB 1017ms 0ms nim/clang 2.2.2
rust 4.rs 1275ms 2.7ms 33.8MB 1250ms 10ms rustc 1.85.1
rust 5.rs 1350ms 10ms 33.8MB 1330ms 7ms rustc 1.85.1
rust 3.rs 1456ms 37ms 49.8MB 1427ms 20ms rustc 1.85.1

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 88ms 2.3ms 5.5MB 80ms 0ms nim 2.2.2
nim 2.nim 93ms 2.6ms 5.8MB 80ms 0ms nim/clang 2.2.2
rust 4.rs 119ms 2.7ms 5.8MB 110ms 0ms rustc 1.85.1
rust 5.rs 127ms 3.5ms 5.8MB 117ms 0ms rustc 1.85.1
rust 3.rs 143ms 2.0ms 7.8MB 130ms 0ms rustc 1.85.1

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-m.rs 515ms 33ms 9.1MB 1920ms 73ms rustc 1.85.1
rust 5-m.rs 705ms 15ms 5.5MB 2663ms 83ms rustc 1.85.1
rust 1-m.rs 972ms 6.4ms 8.5MB 3587ms 207ms rustc 1.85.1
rust 3.rs 1150ms 20ms 9.3MB 1100ms 37ms rustc 1.85.1
rust 4.rs 1914ms 27ms 7.4MB 1900ms 0ms rustc 1.85.1
nim 1.nim timeout 0.0ms 551.4MB 2497ms 2040ms nim 2.2.2
nim 1.nim timeout 0.0ms 559.8MB 2490ms 2047ms nim/clang 2.2.2

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5-m.rs 52ms 1.0ms 3.4MB 157ms 10ms rustc 1.85.1
rust 3-m.rs 57ms 3.9ms 4.4MB 173ms 13ms rustc 1.85.1
rust 3.rs 73ms 1.3ms 4.0MB 63ms 0ms rustc 1.85.1
rust 1-m.rs 75ms 0.5ms 3.8MB 243ms 17ms rustc 1.85.1
rust 4.rs 116ms 2.5ms 3.3MB 107ms 0ms rustc 1.85.1
nim 1.nim 4356ms 55ms 519.8MB 2120ms 1803ms nim/clang 2.2.2
nim 1.nim 4452ms 76ms 519.4MB 2183ms 1837ms nim 2.2.2

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 122ms 2.6ms 3.6MB 110ms 0ms rustc 1.85.1
rust 2.rs 422ms 2.5ms 3.6MB 410ms 0ms rustc 1.85.1

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 34ms 1.7ms 2.9MB 27ms 0ms rustc 1.85.1
rust 2.rs 77ms 0.9ms 3.0MB 70ms 0ms rustc 1.85.1

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-im.rs 410ms 2.4ms 2.1MB 1577ms 0ms rustc 1.85.1
rust 5-m.rs 571ms 5.2ms 2.0MB 2193ms 0ms rustc 1.85.1
rust 2-im.rs 627ms 5.5ms 2.0MB 2410ms 0ms rustc 1.85.1
rust 1-m.rs 977ms 9.9ms 2.1MB 3773ms 0ms rustc 1.85.1
rust 3-i.rs 1500ms 2.2ms 1.9MB 1490ms 0ms rustc 1.85.1
rust 2-i.rs 1760ms 2.0ms 1.8MB 1750ms 0ms rustc 1.85.1
rust 1.rs 2692ms 5.3ms 1.8MB 2683ms 0ms rustc 1.85.1

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-im.rs 38ms 0.2ms 2.1MB 123ms 0ms rustc 1.85.1
rust 5-m.rs 55ms 2.1ms 2.0MB 177ms 0ms rustc 1.85.1
rust 2-im.rs 60ms 0.2ms 2.1MB 200ms 0ms rustc 1.85.1
rust 1-m.rs 87ms 1.2ms 2.1MB 310ms 0ms rustc 1.85.1
rust 3-i.rs 126ms 1.6ms 1.9MB 120ms 0ms rustc 1.85.1
rust 2-i.rs 150ms 1.0ms 1.8MB 140ms 0ms rustc 1.85.1
rust 1.rs 229ms 0.4ms 1.8MB 220ms 0ms rustc 1.85.1

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5c-m.rs 90ms 0.3ms 3.2MB 263ms 0ms rustc 1.85.1
rust 5-m.rs 95ms 0.8ms 3.2MB 290ms 0ms rustc 1.85.1
rust 6.rs 143ms 0.2ms 1.9MB 133ms 0ms rustc 1.85.1
rust 1c.rs 163ms 1.1ms 1.9MB 153ms 0ms rustc 1.85.1
nim 2.nim 187ms 0.9ms 1.5MB 177ms 0ms nim 2.2.2
rust 1.rs 195ms 0.5ms 1.9MB 183ms 0ms rustc 1.85.1
nim 2.nim 238ms 0.7ms 1.8MB 227ms 0ms nim/clang 2.2.2
nim 1.nim 556ms 1.1ms 1.8MB 447ms 93ms nim/clang 2.2.2
nim 1.nim 579ms 0.3ms 1.5MB 467ms 97ms nim 2.2.2

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5c-m.rs 16ms 0.3ms 3.2MB 23ms 0ms rustc 1.85.1
rust 5-m.rs 17ms 0.6ms 3.3MB 30ms 0ms rustc 1.85.1
rust 6.rs 17ms 0.8ms 1.9MB 10ms 0ms rustc 1.85.1
rust 1c.rs 19ms 0.1ms 1.9MB 10ms 0ms rustc 1.85.1
rust 1.rs 22ms 0.4ms 1.9MB 10ms 0ms rustc 1.85.1
nim 2.nim 22ms 0.4ms 1.5MB 13ms 0ms nim 2.2.2
nim 2.nim 26ms 0.4ms 1.8MB 20ms 0ms nim/clang 2.2.2
nim 1.nim 58ms 0.2ms 1.8MB 40ms 7ms nim/clang 2.2.2
nim 1.nim 62ms 1.0ms 1.5MB 43ms 7ms nim 2.2.2

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1-m.rs 290ms 60ms 84.0MB 173ms 503ms rustc 1.85.1
rust 2-m.rs 364ms 16ms 70.9MB 253ms 867ms rustc 1.85.1
rust 1-http2.rs 379ms 64ms 58.0MB 867ms 423ms rustc 1.85.1
rust 2-http2.rs 467ms 58ms 64.2MB 1067ms 527ms rustc 1.85.1

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1-m.rs 42ms 3.1ms 15.8MB 17ms 57ms rustc 1.85.1
rust 2-m.rs 81ms 7.9ms 21.8MB 27ms 167ms rustc 1.85.1
rust 1-http2.rs 187ms 57ms 23.3MB 443ms 180ms rustc 1.85.1
rust 2-http2.rs 224ms 48ms 25.5MB 577ms 187ms rustc 1.85.1

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5-i.rs 30ms 1.2ms 9.8MB 13ms 3ms rustc 1.85.1
rust 4-i.rs 34ms 2.7ms 7.9MB 23ms 0ms rustc 1.85.1
rust 3.rs 61ms 1.3ms 32.0MB 40ms 10ms rustc 1.85.1
rust 2.rs 62ms 1.6ms 33.8MB 37ms 13ms rustc 1.85.1
rust 1.rs 103ms 1.3ms 67.4MB 70ms 20ms rustc 1.85.1

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5-i.rs 208ms 3.5ms 52.6MB 187ms 7ms rustc 1.85.1
rust 4-i.rs 257ms 1.3ms 53.6MB 203ms 37ms rustc 1.85.1
rust 2.rs 404ms 1.3ms 237.6MB 300ms 90ms rustc 1.85.1
rust 3.rs 412ms 3.5ms 237.6MB 303ms 97ms rustc 1.85.1
rust 1.rs 698ms 3.3ms 550.2MB 457ms 230ms rustc 1.85.1

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 226ms 1.7ms 26.7MB 670ms 10ms rustc 1.85.1
rust 8.rs 469ms 8.7ms 22.5MB 447ms 7ms rustc 1.85.1

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 30ms 1.9ms 16.0MB 60ms 0ms rustc 1.85.1
rust 8.rs 60ms 0.6ms 11.4MB 50ms 0ms rustc 1.85.1

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 39ms 9.6ms 1.8MB 30ms 0ms rustc 1.85.1
rust 1.rs 47ms 2.9ms 2.0MB 40ms 0ms rustc 1.85.1
nim 2.nim 111ms 1.8ms 1.4MB 103ms 0ms nim 2.2.2
nim 2.nim 112ms 0.9ms 1.6MB 100ms 0ms nim/clang 2.2.2
nim 1.nim timeout 0.0ms 1.3MB 4990ms 0ms nim 2.2.2
nim 1.nim timeout 0.0ms 1.5MB 4990ms 0ms nim/clang 2.2.2

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 155ms 14ms 1.9MB 147ms 0ms rustc 1.85.1
rust 1.rs 187ms 18ms 2.0MB 180ms 0ms rustc 1.85.1
nim 2.nim 328ms 2.7ms 1.6MB 317ms 0ms nim/clang 2.2.2
nim 2.nim 331ms 1.6ms 1.4MB 320ms 0ms nim 2.2.2
nim 1.nim timeout 0.0ms 1.3MB 4990ms 0ms nim 2.2.2
nim 1.nim timeout 0.0ms 1.5MB 4990ms 0ms nim/clang 2.2.2

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 22ms 0.3ms 1.8MB 13ms 0ms rustc 1.85.1
rust 1.rs 30ms 0.7ms 1.9MB 20ms 0ms rustc 1.85.1
nim 2.nim 49ms 0.9ms 1.6MB 40ms 0ms nim/clang 2.2.2
nim 2.nim 50ms 0.3ms 1.3MB 40ms 0ms nim 2.2.2
nim 1.nim 442ms 4.2ms 1.8MB 433ms 0ms nim/clang 2.2.2
nim 1.nim 486ms 4.9ms 1.3MB 477ms 0ms nim 2.2.2

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 526ms 2.3ms 34.6MB 510ms 3ms nim 2.2.2
nim 1.nim 651ms 20ms 35.0MB 633ms 3ms nim/clang 2.2.2
rust 1.rs 763ms 45ms 33.8MB 737ms 10ms rustc 1.85.1

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 115ms 1.7ms 9.6MB 103ms 0ms nim 2.2.2
nim 1.nim 135ms 1.5ms 9.9MB 120ms 0ms nim/clang 2.2.2
rust 1.rs 153ms 2.9ms 9.8MB 143ms 0ms rustc 1.85.1

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 290ms 15ms 41.5MB 277ms 0ms nim 2.2.2
rust 1.rs 311ms 3.9ms 40.9MB 297ms 0ms rustc 1.85.1
rust 2.rs 315ms 2.5ms 6.6MB 303ms 0ms rustc 1.85.1
nim 1.nim 349ms 1.9ms 41.8MB 333ms 0ms nim/clang 2.2.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 52ms 1.5ms 11.5MB 40ms 0ms nim 2.2.2
nim 1.nim 57ms 2.7ms 11.8MB 50ms 0ms nim/clang 2.2.2
rust 1.rs 63ms 2.3ms 11.6MB 53ms 0ms rustc 1.85.1
rust 2.rs 77ms 0.9ms 2.9MB 70ms 0ms rustc 1.85.1

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 1524ms 4.2ms 2.7MB 1303ms 203ms rustc 1.85.1
rust 2.rs 1708ms 4.8ms 2.6MB 1630ms 67ms rustc 1.85.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 324ms 4.6ms 2.4MB 297ms 13ms rustc 1.85.1
rust 2.rs 383ms 6.3ms 2.4MB 373ms 0ms rustc 1.85.1

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 7.rs 445ms 11ms 77.5MB 463ms 17ms rustc 1.85.1
nim 1.nim 1632ms 7.3ms 164.3MB 1600ms 23ms nim/clang 2.2.2
nim 1.nim 1694ms 5.0ms 163.8MB 1663ms 20ms nim 2.2.2

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 7.rs 49ms 0.9ms 12.4MB 40ms 0ms rustc 1.85.1
nim 1.nim 173ms 1.4ms 20.9MB 157ms 3ms nim/clang 2.2.2
nim 1.nim 176ms 0.9ms 20.6MB 160ms 0ms nim 2.2.2

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0.rs 120ms 2.0ms 1.9MB 110ms 0ms rustc 1.85.1
rust 1.rs 1453ms 31ms 1.9MB 1443ms 0ms rustc 1.85.1

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0.rs 33ms 1.0ms 1.8MB 23ms 0ms rustc 1.85.1
rust 1.rs 365ms 3.7ms 1.9MB 357ms 0ms rustc 1.85.1