Nim VS C# benchmarks

Current benchmark data was generated on Mon Dec 30 2024, 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 766ms 2.6ms 34.8MB 750ms 3ms nim 2.2.0
csharp 1.cs 934ms 19ms 178.8MB 943ms 113ms dotnet/aot 9.0.101
csharp 1.cs 937ms 13ms 190.1MB 943ms 147ms dotnet 9.0.101
nim 2.nim 957ms 3.4ms 34.2MB 943ms 3ms nim/clang 2.2.0
csharp 1.cs 1755ms 97ms 101.4MB 1977ms 223ms mono 6.12.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 76ms 3.6ms 5.5MB 67ms 0ms nim 2.2.0
nim 2.nim 92ms 0.6ms 5.8MB 80ms 0ms nim/clang 2.2.0
csharp 1.cs 116ms 6.0ms 40.9MB 90ms 20ms dotnet/aot 9.0.101
csharp 1.cs 145ms 4.8ms 46.0MB 123ms 13ms mono 6.12.0
csharp 1.cs 202ms 19ms 61.8MB 153ms 33ms dotnet 9.0.101

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1-m.cs 2209ms 28ms 66.3MB 7577ms 63ms dotnet/aot 9.0.101
csharp 1-m.cs 2697ms 176ms 81.2MB 8370ms 97ms dotnet 9.0.101
nim 1.nim timeout 0.0ms 546.2MB 2487ms 2057ms nim 2.2.0
nim 1.nim timeout 0.0ms 552.6MB 2530ms 2013ms nim/clang 2.2.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1-m.cs 174ms 1.5ms 29.0MB 487ms 20ms dotnet/aot 9.0.101
csharp 1-m.cs 275ms 10ms 50.2MB 780ms 23ms dotnet 9.0.101
nim 1.nim 4364ms 34ms 518.7MB 2180ms 1760ms nim/clang 2.2.0
nim 1.nim 4534ms 2.9ms 518.2MB 2227ms 1877ms nim 2.2.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 128ms 5.1ms 32.6MB 353ms 83ms dotnet/aot 9.0.101
nim 2.nim 184ms 1.6ms 1.5MB 170ms 0ms nim 2.2.0
csharp 5-m.cs 200ms 2.9ms 49.2MB 467ms 120ms dotnet 9.0.101
nim 2.nim 239ms 0.6ms 1.8MB 227ms 0ms nim/clang 2.2.0
csharp 5-m.cs 254ms 11ms 60.7MB 697ms 107ms mono 6.12.0
nim 1.nim 572ms 3.7ms 1.8MB 443ms 117ms nim/clang 2.2.0
nim 1.nim 597ms 1.9ms 1.5MB 467ms 117ms nim 2.2.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 21ms 0.3ms 1.5MB 10ms 0ms nim 2.2.0
nim 2.nim 25ms 0.1ms 1.8MB 13ms 0ms nim/clang 2.2.0
csharp 5-m.cs 27ms 1.0ms 25.2MB 37ms 17ms dotnet/aot 9.0.101
nim 1.nim 62ms 3.4ms 1.8MB 40ms 10ms nim/clang 2.2.0
nim 1.nim 62ms 0.6ms 1.5MB 40ms 7ms nim 2.2.0
csharp 5-m.cs 64ms 4.7ms 46.9MB 83ms 20ms dotnet 9.0.101
csharp 5-m.cs 72ms 4.0ms 42.9MB 103ms 23ms mono 6.12.0

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.0
nim 1.nim 1.1ms 0.1ms 1.8MB 0ms 0ms nim/clang 2.2.0
csharp 1.cs 11ms 8.6ms 15.6MB 0ms 0ms dotnet/aot 9.0.101
csharp 1.cs 30ms 0.6ms 21.9MB 16ms 2ms mono 6.12.0
csharp 1.cs 36ms 0.9ms 32.0MB 16ms 12ms dotnet 9.0.101

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2-http2.cs 533ms 7.2ms 122.6MB 737ms 133ms dotnet 9.0.101
csharp 2-m.cs 684ms 22ms 160.8MB 757ms 610ms dotnet 9.0.101
csharp 2-http3.cs 697ms 20ms 158.8MB 1157ms 253ms dotnet 9.0.101
csharp 1-m.cs 813ms 30ms 175.3MB 1137ms 680ms dotnet 9.0.101
nim 1.nim 971ms 14ms 99.4MB 257ms 690ms nim/clang 2.2.0
nim 1.nim 988ms 12ms 99.3MB 257ms 700ms nim 2.2.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 159ms 2.7ms 18.1MB 33ms 110ms nim 2.2.0
nim 1.nim 164ms 4.9ms 18.4MB 43ms 103ms nim/clang 2.2.0
csharp 2.cs 394ms 16ms 98.6MB 380ms 197ms dotnet 9.0.101
csharp 2-http2.cs 446ms 18ms 97.9MB 487ms 100ms dotnet 9.0.101
csharp 1-m.cs 451ms 7.4ms 109.4MB 503ms 257ms dotnet 9.0.101
csharp 2-http3.cs 496ms 4.0ms 108.0MB 593ms 110ms dotnet 9.0.101

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 95ms 1.0ms 13.8MB 80ms 3ms dotnet/aot 9.0.101
nim 2.nim 110ms 0.9ms 1.9MB 100ms 0ms nim/clang 2.2.0
nim 2.nim 114ms 1.4ms 1.4MB 103ms 0ms nim 2.2.0
csharp 2.cs 147ms 2.3ms 24.5MB 133ms 0ms mono 6.12.0
csharp 2.cs 250ms 1.2ms 33.4MB 233ms 10ms dotnet 9.0.101
csharp 1.cs 1062ms 6.0ms 15.0MB 1037ms 10ms dotnet/aot 9.0.101
csharp 1.cs 1358ms 84ms 36.9MB 1343ms 20ms dotnet 9.0.101
csharp 1.cs 3290ms 18ms 47.6MB 3247ms 37ms mono 6.12.0
nim 1.nim timeout 0.0ms 1.3MB 4987ms 0ms nim 2.2.0
nim 1.nim timeout 0.0ms 1.5MB 4990ms 0ms nim/clang 2.2.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 263ms 0.8ms 11.7MB 250ms 0ms dotnet/aot 9.0.101
nim 2.nim 321ms 3.0ms 1.6MB 310ms 0ms nim/clang 2.2.0
nim 2.nim 338ms 2.7ms 1.5MB 327ms 0ms nim 2.2.0
csharp 2.cs 362ms 9.5ms 24.8MB 347ms 3ms mono 6.12.0
csharp 2.cs 407ms 3.9ms 35.6MB 393ms 7ms dotnet 9.0.101
csharp 1.cs 3145ms 6.5ms 17.2MB 3117ms 13ms dotnet/aot 9.0.101
csharp 1.cs 3577ms 12ms 39.1MB 3560ms 23ms dotnet 9.0.101
csharp 1.cs timeout 0.0ms 47.6MB 4937ms 53ms mono 6.12.0
nim 1.nim timeout 0.0ms 1.3MB 4990ms 0ms nim 2.2.0
nim 1.nim timeout 0.0ms 1.5MB 4990ms 0ms nim/clang 2.2.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 49ms 2.0ms 1.5MB 40ms 0ms nim/clang 2.2.0
nim 2.nim 51ms 1.7ms 1.3MB 43ms 0ms nim 2.2.0
csharp 2.cs 53ms 0.9ms 15.7MB 43ms 0ms dotnet/aot 9.0.101
csharp 2.cs 93ms 3.1ms 22.8MB 83ms 0ms mono 6.12.0
csharp 2.cs 174ms 5.4ms 35.3MB 150ms 7ms dotnet 9.0.101
nim 1.nim 494ms 5.1ms 1.5MB 480ms 0ms nim/clang 2.2.0
nim 1.nim 497ms 11ms 1.3MB 483ms 0ms nim 2.2.0
csharp 1.cs 1612ms 13ms 36.4MB 1597ms 13ms dotnet 9.0.101
csharp 1.cs 1800ms 3.3ms 16.9MB 1780ms 3ms dotnet/aot 9.0.101
csharp 1.cs 1808ms 4.2ms 30.8MB 1797ms 0ms mono 6.12.0

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 385ms 1.1ms 4.8MB 370ms 0ms nim/clang 2.2.0
nim 1.nim 576ms 3.5ms 4.5MB 567ms 0ms nim 2.2.0
csharp 2.cs 1109ms 65ms 46.0MB 1080ms 7ms dotnet 9.0.101
csharp 1.cs 2104ms 69ms 42.8MB 2070ms 7ms dotnet 9.0.101
csharp 3.cs 2455ms 20ms 42.8MB 2427ms 13ms dotnet 9.0.101
csharp 3.cs 2516ms 5.9ms 22.3MB 2500ms 0ms dotnet/aot 9.0.101
csharp 1.cs 3557ms 4.9ms 22.2MB 3540ms 3ms dotnet/aot 9.0.101
csharp 1.cs timeout 0.0ms 24.3MB 4980ms 3ms mono 6.12.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 18ms 0.5ms 1.9MB 10ms 0ms nim/clang 2.2.0
nim 1.nim 27ms 1.4ms 1.6MB 17ms 0ms nim 2.2.0
csharp 3.cs 118ms 2.6ms 17.4MB 100ms 3ms dotnet/aot 9.0.101
csharp 2.cs 134ms 6.8ms 43.1MB 110ms 10ms dotnet 9.0.101
csharp 1.cs 137ms 2.6ms 39.7MB 117ms 3ms dotnet 9.0.101
csharp 1.cs 156ms 1.9ms 19.2MB 140ms 0ms dotnet/aot 9.0.101
csharp 3.cs 166ms 3.9ms 39.9MB 153ms 0ms dotnet 9.0.101
csharp 1.cs 573ms 11ms 23.4MB 550ms 7ms mono 6.12.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 540ms 2.8ms 123.4MB 457ms 110ms dotnet/aot 9.0.101
nim 1.nim 550ms 4.2ms 34.9MB 527ms 7ms nim 2.2.0
csharp 1.cs 592ms 9.8ms 152.5MB 530ms 120ms dotnet/aot 9.0.101
nim 1.nim 601ms 10.0ms 35.2MB 583ms 7ms nim/clang 2.2.0
csharp 2.cs 680ms 21ms 142.0MB 610ms 117ms dotnet 9.0.101
csharp 1.cs 743ms 44ms 170.9MB 660ms 140ms dotnet 9.0.101
csharp 1.cs 1301ms 44ms 146.2MB 1470ms 203ms mono 6.12.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 119ms 0.7ms 9.6MB 107ms 0ms nim 2.2.0
nim 1.nim 129ms 2.9ms 9.9MB 120ms 0ms nim/clang 2.2.0
csharp 2.cs 135ms 1.9ms 64.9MB 100ms 37ms dotnet/aot 9.0.101
csharp 1.cs 154ms 4.0ms 78.9MB 110ms 57ms dotnet/aot 9.0.101
csharp 2.cs 258ms 2.7ms 83.9MB 217ms 43ms dotnet 9.0.101
csharp 1.cs 265ms 1.4ms 73.2MB 223ms 47ms mono 6.12.0
csharp 1.cs 278ms 7.3ms 101.3MB 237ms 57ms dotnet 9.0.101

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 319ms 1.8ms 1.8MB 310ms 0ms nim 2.2.0
nim 2.nim 342ms 2.3ms 2.0MB 327ms 0ms nim/clang 2.2.0
csharp 9.cs 359ms 1.6ms 34.0MB 337ms 7ms dotnet 9.0.101
csharp 8.cs 373ms 3.9ms 15.7MB 357ms 0ms dotnet/aot 9.0.101
csharp 8.cs 426ms 13ms 33.8MB 390ms 13ms dotnet 9.0.101
csharp 8.cs 1248ms 3.3ms 24.1MB 1237ms 0ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 35ms 0.9ms 1.8MB 23ms 0ms nim 2.2.0
nim 2.nim 36ms 0.3ms 2.0MB 30ms 0ms nim/clang 2.2.0
csharp 8.cs 46ms 0.6ms 15.9MB 33ms 0ms dotnet/aot 9.0.101
csharp 9.cs 91ms 0.7ms 33.8MB 70ms 10ms dotnet 9.0.101
csharp 8.cs 104ms 17ms 33.7MB 73ms 7ms dotnet 9.0.101
csharp 8.cs 161ms 1.4ms 22.5MB 147ms 3ms mono 6.12.0

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 262ms 5.5ms 41.5MB 250ms 0ms nim 2.2.0
csharp 1.cs 300ms 3.9ms 53.0MB 280ms 3ms dotnet/aot 9.0.101
nim 1.nim 317ms 11ms 41.8MB 300ms 0ms nim/clang 2.2.0
csharp 1.cs 346ms 9.8ms 104.3MB 320ms 10ms dotnet 9.0.101
csharp 2.cs 397ms 3.3ms 39.8MB 373ms 10ms dotnet 9.0.101
csharp 2.cs 421ms 2.4ms 20.9MB 410ms 0ms dotnet/aot 9.0.101
csharp 1.cs 533ms 4.1ms 87.7MB 510ms 13ms mono 6.12.0
csharp 2.cs 1854ms 4.3ms 29.5MB 1840ms 3ms mono 6.12.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 53ms 0.6ms 11.5MB 43ms 0ms nim 2.2.0
nim 1.nim 63ms 3.5ms 11.8MB 53ms 0ms nim/clang 2.2.0
csharp 1.cs 69ms 2.3ms 23.8MB 50ms 7ms dotnet/aot 9.0.101
csharp 1.cs 106ms 6.1ms 43.3MB 80ms 10ms dotnet 9.0.101
csharp 2.cs 108ms 2.4ms 15.9MB 97ms 0ms dotnet/aot 9.0.101
csharp 2.cs 136ms 16ms 36.4MB 110ms 3ms dotnet 9.0.101
csharp 1.cs 144ms 3.6ms 38.0MB 127ms 7ms mono 6.12.0
csharp 2.cs 482ms 5.6ms 24.9MB 467ms 3ms mono 6.12.0

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 1623ms 5.2ms 151.9MB 1587ms 20ms nim/clang 2.2.0
nim 1.nim 1645ms 3.9ms 151.5MB 1607ms 23ms nim 2.2.0
csharp 6.cs 1761ms 5.2ms 429.6MB 1657ms 153ms dotnet/aot 9.0.101
csharp 5.cs 2106ms 45ms 454.9MB 2140ms 210ms dotnet 9.0.101
csharp 6.cs 2759ms 116ms 449.2MB 2697ms 177ms dotnet 9.0.101
csharp 5.cs 4231ms 11ms 430.8MB 4123ms 163ms dotnet/aot 9.0.101

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 172ms 2.5ms 17.5MB 157ms 0ms nim/clang 2.2.0
nim 1.nim 173ms 1.9ms 17.2MB 160ms 0ms nim 2.2.0
csharp 6.cs 190ms 0.6ms 54.2MB 163ms 23ms dotnet/aot 9.0.101
csharp 5.cs 291ms 5.7ms 80.4MB 253ms 37ms dotnet 9.0.101
csharp 6.cs 391ms 6.5ms 76.7MB 367ms 20ms dotnet 9.0.101
csharp 5.cs 436ms 0.8ms 57.4MB 413ms 17ms dotnet/aot 9.0.101

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 1858ms 0.9ms 18.2MB 7250ms 10ms dotnet/aot 9.0.101
csharp 3-m.cs 2189ms 252ms 38.0MB 6870ms 10ms dotnet 9.0.101
nim 1.nim 3575ms 2.8ms 1.6MB 3563ms 0ms nim/clang 2.2.0
nim 1.nim 3593ms 7.9ms 1.4MB 3583ms 0ms nim 2.2.0
csharp 3-m.cs 4588ms 37ms 28.7MB 17757ms 13ms mono 6.12.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 476ms 1.0ms 18.3MB 1810ms 7ms dotnet/aot 9.0.101
csharp 3-m.cs 530ms 2.0ms 37.9MB 1857ms 17ms dotnet 9.0.101
nim 1.nim 895ms 0.8ms 1.5MB 883ms 0ms nim/clang 2.2.0
nim 1.nim 902ms 3.4ms 1.3MB 893ms 0ms nim 2.2.0
csharp 3-m.cs 1305ms 182ms 34.4MB 4597ms 17ms mono 6.12.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 129ms 1.1ms 18.5MB 443ms 7ms dotnet/aot 9.0.101
csharp 3-m.cs 179ms 1.4ms 36.5MB 507ms 0ms dotnet 9.0.101
nim 1.nim 226ms 0.3ms 1.6MB 220ms 0ms nim 2.2.0
nim 1.nim 226ms 0.5ms 1.5MB 213ms 0ms nim/clang 2.2.0
csharp 3-m.cs 355ms 13ms 30.3MB 1183ms 10ms mono 6.12.0