Nim VS Rust benchmarks

Current benchmark data was generated on Mon May 19 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
nim 2.nim 836ms 40ms 34.9MB 817ms 7ms nim 2.2.4
nim 2.nim 971ms 5.9ms 35.2MB 953ms 3ms nim/clang 2.2.4
rust 4.rs 1281ms 13ms 33.8MB 1260ms 7ms rustc 1.87.0
rust 5.rs 1340ms 6.3ms 33.8MB 1317ms 10ms rustc 1.87.0
rust 3.rs 1496ms 49ms 49.8MB 1463ms 17ms rustc 1.87.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 77ms 1.2ms 5.5MB 70ms 0ms nim 2.2.4
nim 2.nim 93ms 2.7ms 5.8MB 80ms 0ms nim/clang 2.2.4
rust 4.rs 118ms 0.3ms 5.6MB 110ms 0ms rustc 1.87.0
rust 5.rs 128ms 5.4ms 5.8MB 117ms 0ms rustc 1.87.0
rust 3.rs 142ms 6.5ms 7.8MB 130ms 0ms rustc 1.87.0

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-m.rs 518ms 38ms 9.1MB 1957ms 60ms rustc 1.87.0
rust 5-m.rs 679ms 12ms 5.5MB 2580ms 67ms rustc 1.87.0
rust 1-m.rs 955ms 8.3ms 7.4MB 3497ms 227ms rustc 1.87.0
rust 3.rs 1110ms 9.5ms 9.3MB 1070ms 23ms rustc 1.87.0
rust 4.rs 1921ms 31ms 6.9MB 1903ms 0ms rustc 1.87.0
nim 1.nim timeout 0.0ms 575.4MB 2623ms 1900ms nim 2.2.4
nim 1.nim timeout 0.0ms 575.7MB 2560ms 1967ms nim/clang 2.2.4

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5-m.rs 51ms 1.1ms 3.3MB 153ms 10ms rustc 1.87.0
rust 3-m.rs 55ms 3.2ms 4.1MB 173ms 10ms rustc 1.87.0
rust 3.rs 69ms 0.8ms 4.0MB 60ms 0ms rustc 1.87.0
rust 1-m.rs 73ms 0.3ms 3.5MB 237ms 17ms rustc 1.87.0
rust 4.rs 115ms 1.2ms 3.1MB 107ms 0ms rustc 1.87.0
nim 1.nim 4094ms 5.6ms 519.3MB 2117ms 1553ms nim 2.2.4
nim 1.nim 4109ms 27ms 518.7MB 2100ms 1580ms nim/clang 2.2.4

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 6.rs 88ms 2.2ms 1.9MB 80ms 0ms rustc 1.87.0
rust 5c-m.rs 88ms 0.3ms 3.4MB 240ms 0ms rustc 1.87.0
rust 5-m.rs 94ms 0.1ms 3.2MB 290ms 3ms rustc 1.87.0
rust 1c.rs 163ms 0.5ms 1.9MB 150ms 0ms rustc 1.87.0
nim 2.nim 188ms 2.8ms 1.5MB 180ms 0ms nim 2.2.4
rust 1.rs 194ms 0.9ms 2.0MB 183ms 0ms rustc 1.87.0
nim 2.nim 243ms 2.1ms 1.8MB 230ms 0ms nim/clang 2.2.4
nim 1.nim 533ms 0.9ms 1.8MB 453ms 67ms nim/clang 2.2.4
nim 1.nim 557ms 2.9ms 1.5MB 470ms 73ms nim 2.2.4

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 6.rs 11ms 0.1ms 1.9MB 0ms 0ms rustc 1.87.0
rust 5c-m.rs 15ms 0.3ms 3.2MB 20ms 0ms rustc 1.87.0
rust 5-m.rs 16ms 0.6ms 3.2MB 30ms 0ms rustc 1.87.0
rust 1c.rs 19ms 0.4ms 1.9MB 10ms 0ms rustc 1.87.0
rust 1.rs 21ms 0.3ms 1.9MB 10ms 0ms rustc 1.87.0
nim 2.nim 22ms 0.7ms 1.5MB 10ms 0ms nim 2.2.4
nim 2.nim 27ms 1.0ms 1.8MB 20ms 0ms nim/clang 2.2.4
nim 1.nim 56ms 0.8ms 1.8MB 43ms 0ms nim/clang 2.2.4
nim 1.nim 59ms 1.8ms 1.5MB 40ms 3ms nim 2.2.4

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 1.0ms 0.0ms 1.6MB 0ms 0ms nim 2.2.4
nim 1.nim 1.1ms 0.0ms 1.9MB 0ms 0ms nim/clang 2.2.4
rust 1.rs 1.2ms 0.0ms 1.8MB 0ms 0ms rustc 1.87.0
rust 1.rs 1.7ms 0.6ms 1.8MB 0ms 0ms rustc 1.89.0-nightly

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 35ms 7.9ms 1.8MB 27ms 0ms rustc 1.87.0
rust 1.rs 51ms 6.1ms 1.9MB 43ms 0ms rustc 1.87.0
nim 2.nim 110ms 1.5ms 1.6MB 100ms 0ms nim/clang 2.2.4
nim 2.nim 114ms 1.4ms 1.4MB 107ms 0ms nim 2.2.4
nim 1.nim timeout 0.0ms 1.3MB 4990ms 0ms nim 2.2.4
nim 1.nim timeout 0.0ms 1.5MB 4990ms 0ms nim/clang 2.2.4

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 139ms 28ms 1.9MB 130ms 0ms rustc 1.87.0
rust 1.rs 191ms 16ms 1.9MB 183ms 0ms rustc 1.87.0
nim 2.nim 325ms 2.6ms 1.6MB 317ms 0ms nim/clang 2.2.4
nim 2.nim 336ms 4.1ms 1.4MB 327ms 0ms nim 2.2.4
nim 1.nim timeout 0.0ms 1.3MB 4990ms 0ms nim 2.2.4
nim 1.nim timeout 0.0ms 1.5MB 4990ms 0ms nim/clang 2.2.4

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 0-unsafe.rs 24ms 1.0ms 1.8MB 17ms 0ms rustc 1.87.0
rust 1.rs 31ms 0.2ms 1.8MB 20ms 0ms rustc 1.87.0
nim 2.nim 50ms 1.8ms 1.5MB 40ms 0ms nim/clang 2.2.4
nim 2.nim 52ms 1.0ms 1.3MB 43ms 0ms nim 2.2.4
nim 1.nim 482ms 4.8ms 1.3MB 477ms 0ms nim 2.2.4
nim 1.nim 488ms 14ms 1.5MB 477ms 0ms nim/clang 2.2.4

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 9.rs 265ms 15ms 4.9MB 253ms 0ms rustc 1.89.0-nightly
rust 8.rs 291ms 0.6ms 4.8MB 280ms 0ms rustc 1.87.0
nim 1.nim 387ms 0.4ms 4.8MB 380ms 0ms nim/clang 2.2.4
nim 1.nim 576ms 1.5ms 4.5MB 563ms 0ms nim 2.2.4

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 9.rs 13ms 0.5ms 2.0MB 10ms 0ms rustc 1.89.0-nightly
rust 8.rs 14ms 0.2ms 1.9MB 10ms 0ms rustc 1.87.0
nim 1.nim 19ms 0.5ms 1.9MB 10ms 0ms nim/clang 2.2.4
nim 1.nim 27ms 1.2ms 1.6MB 20ms 0ms nim 2.2.4

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 552ms 1.9ms 34.9MB 530ms 7ms nim 2.2.4
nim 1.nim 634ms 34ms 35.2MB 613ms 10ms nim/clang 2.2.4
rust 1.rs 698ms 4.2ms 33.8MB 673ms 10ms rustc 1.87.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 120ms 2.4ms 9.6MB 110ms 0ms nim 2.2.4
nim 1.nim 135ms 2.2ms 9.9MB 123ms 0ms nim/clang 2.2.4
rust 1.rs 153ms 2.6ms 9.8MB 143ms 0ms rustc 1.87.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 164ms 0.6ms 1.8MB 160ms 0ms rustc 1.87.0
rust 7-i.rs 218ms 0.5ms 1.8MB 210ms 0ms rustc 1.87.0
rust 1.rs 229ms 1.1ms 1.8MB 220ms 0ms rustc 1.87.0
rust 2.rs 279ms 0.0ms 1.8MB 270ms 0ms rustc 1.87.0
rust 3.rs 279ms 0.5ms 1.8MB 270ms 0ms rustc 1.89.0-nightly
nim 2.nim 319ms 1.7ms 1.8MB 310ms 0ms nim 2.2.4
nim 2.nim 340ms 0.5ms 2.0MB 330ms 0ms nim/clang 2.2.4

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.4ms 1.8MB 20ms 0ms rustc 1.87.0
rust 1.rs 25ms 0.4ms 1.8MB 20ms 0ms rustc 1.87.0
rust 2.rs 30ms 0.0ms 1.6MB 20ms 0ms rustc 1.87.0
rust 3.rs 30ms 0.1ms 1.8MB 20ms 0ms rustc 1.89.0-nightly
nim 2.nim 35ms 1.0ms 1.8MB 30ms 0ms nim 2.2.4
nim 2.nim 40ms 6.2ms 2.0MB 33ms 0ms nim/clang 2.2.4

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 267ms 0.8ms 41.5MB 253ms 0ms nim 2.2.4
rust 2.rs 301ms 0.2ms 6.6MB 290ms 0ms rustc 1.87.0
nim 1.nim 314ms 3.5ms 41.8MB 303ms 0ms nim/clang 2.2.4
rust 1.rs 331ms 4.3ms 40.9MB 317ms 0ms rustc 1.87.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 51ms 1.1ms 11.6MB 40ms 0ms nim 2.2.4
nim 1.nim 63ms 1.6ms 11.8MB 53ms 0ms nim/clang 2.2.4
rust 1.rs 67ms 0.1ms 11.6MB 57ms 0ms rustc 1.87.0
rust 2.rs 77ms 2.0ms 2.9MB 70ms 0ms rustc 1.87.0

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 7.rs 442ms 2.7ms 78.6MB 453ms 17ms rustc 1.87.0
nim 1.nim 1651ms 5.5ms 151.9MB 1620ms 13ms nim/clang 2.2.4
nim 1.nim 1683ms 16ms 152.1MB 1650ms 20ms nim 2.2.4

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 7.rs 51ms 0.8ms 11.6MB 43ms 3ms rustc 1.87.0
nim 1.nim 174ms 3.4ms 17.6MB 160ms 0ms nim/clang 2.2.4
nim 1.nim 176ms 3.6ms 17.2MB 163ms 0ms nim 2.2.4

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 493ms 0.6ms 2.5MB 1910ms 0ms rustc 1.89.0-nightly
rust 7-m.rs 493ms 0.7ms 2.1MB 1910ms 0ms rustc 1.87.0
rust 8.rs 993ms 1.0ms 2.3MB 983ms 0ms rustc 1.89.0-nightly
rust 7.rs 1961ms 4.4ms 1.9MB 1950ms 0ms rustc 1.87.0
rust 2-m.rs 2070ms 3.8ms 2.3MB 8130ms 10ms rustc 1.87.0
nim 1.nim 3587ms 2.7ms 1.6MB 3580ms 0ms nim/clang 2.2.4
nim 1.nim 3610ms 12ms 1.4MB 3597ms 0ms nim 2.2.4
rust 2.rs 4266ms 1.8ms 2.1MB 4257ms 0ms rustc 1.87.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 127ms 0.5ms 2.3MB 467ms 3ms rustc 1.89.0-nightly
rust 7-m.rs 128ms 0.3ms 2.1MB 467ms 3ms rustc 1.87.0
rust 8.rs 251ms 0.6ms 2.0MB 240ms 0ms rustc 1.89.0-nightly
rust 7.rs 493ms 1.4ms 1.8MB 480ms 0ms rustc 1.87.0
rust 2-m.rs 521ms 0.9ms 2.3MB 2030ms 0ms rustc 1.87.0
nim 1.nim 899ms 0.8ms 1.5MB 890ms 0ms nim/clang 2.2.4
nim 1.nim 902ms 1.4ms 1.3MB 893ms 0ms nim 2.2.4
rust 2.rs 1069ms 4.4ms 2.0MB 1063ms 0ms rustc 1.87.0

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.89.0-nightly
rust 7-m.rs 36ms 0.6ms 2.0MB 113ms 0ms rustc 1.87.0
rust 8.rs 65ms 0.9ms 1.9MB 60ms 0ms rustc 1.89.0-nightly
rust 7.rs 128ms 2.5ms 1.8MB 120ms 0ms rustc 1.87.0
rust 2-m.rs 134ms 0.7ms 2.1MB 490ms 3ms rustc 1.87.0
nim 1.nim 226ms 0.1ms 1.5MB 220ms 0ms nim/clang 2.2.4
nim 1.nim 229ms 1.9ms 1.3MB 220ms 0ms nim 2.2.4
rust 2.rs 269ms 1.2ms 1.9MB 260ms 0ms rustc 1.87.0