Zig VS C# benchmarks

Current benchmark data was generated on Sun Jan 29 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz (Model 106)

* -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
csharp 1.cs 1241ms 50ms 383.8MB 1153ms 187ms dotnet/aot 7.0.102
csharp 1.cs 1523ms 25ms 473.5MB 1337ms 230ms dotnet 7.0.102
zig 1.zig 2124ms 12ms 49.1MB 2090ms 17ms zig 0.11.0-dev.1480+f68d3c63d
csharp 1.cs 2191ms 3.7ms 98.5MB 2523ms 157ms mono 6.12.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 125ms 1.7ms 72.0MB 103ms 20ms dotnet/aot 7.0.102
csharp 1.cs 154ms 0.5ms 48.1MB 133ms 13ms mono 6.12.0
zig 1.zig 183ms 1.2ms 7.0MB 170ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 1.cs 255ms 5.7ms 168.2MB 180ms 53ms dotnet 7.0.102

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 3828ms 0.4ms 2.6MB 3800ms 10ms zig 0.11.0-dev.1480+f68d3c63d
csharp 1.cs timeout 0.0ms 111.6MB 4953ms 30ms dotnet 7.0.102
csharp 1.cs timeout 0.0ms 22.8MB 4987ms 3ms dotnet/aot 7.0.102

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 635ms 0.3ms 1.9MB 617ms 3ms zig 0.11.0-dev.1480+f68d3c63d
csharp 1.cs 1019ms 11ms 19.1MB 1013ms 0ms dotnet/aot 7.0.102
csharp 1.cs 1121ms 4.6ms 109.5MB 1067ms 20ms dotnet 7.0.102

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 1293ms 14ms 1.1MB 2520ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 3-i.zig 1576ms 41ms 1.0MB 1567ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 2.zig 2524ms 3.1ms 1.0MB 2513ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 1.zig 3480ms 3.3ms 1.0MB 3470ms 0ms zig 0.11.0-dev.1480+f68d3c63d

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 118ms 0.2ms 1.1MB 210ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 3-i.zig 130ms 0.3ms 1.0MB 120ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 2.zig 217ms 0.2ms 1.0MB 207ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 1.zig 287ms 0.3ms 1.0MB 280ms 0ms zig 0.11.0-dev.1480+f68d3c63d

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 154ms 0.2ms 1.0MB 147ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 5-m.cs 365ms 37ms 71.5MB 553ms 137ms dotnet/aot 7.0.102
csharp 5-m.cs 494ms 36ms 85.9MB 830ms 93ms mono 6.12.0
csharp 5-m.cs 636ms 73ms 161.9MB 1030ms 133ms dotnet 7.0.102

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 18ms 0.7ms 1.0MB 10ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 5.cs 58ms 7.1ms 24.7MB 73ms 10ms dotnet/aot 7.0.102
csharp 5.cs 97ms 14ms 37.8MB 113ms 30ms mono 6.12.0
csharp 5.cs 127ms 16ms 109.3MB 120ms 40ms dotnet 7.0.102

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 1.2ms 0.3ms 1.0MB 0ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 1.cs 5.7ms 0.6ms 10.1MB 0ms 0ms dotnet/aot 7.0.102
csharp 1.cs 19ms 0.7ms 23.6MB 10ms 0ms mono 6.12.0
csharp 1.cs 75ms 3.4ms 101.5MB 20ms 20ms dotnet 7.0.102

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 118ms 0.8ms 14.4MB 100ms 3ms zig 0.11.0-dev.1480+f68d3c63d
csharp 2.cs 432ms 13ms 146.9MB 363ms 40ms dotnet 7.0.102
csharp 1.cs 700ms 2.3ms 217.9MB 670ms 83ms dotnet 7.0.102

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 702ms 0.7ms 75.0MB 660ms 20ms zig 0.11.0-dev.1480+f68d3c63d
csharp 2.cs 1869ms 104ms 337.3MB 1913ms 133ms dotnet 7.0.102
csharp 1.cs 2929ms 15ms 857.7MB 2847ms 397ms dotnet 7.0.102

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6-m.cs 949ms 4.6ms 55.7MB 1473ms 27ms dotnet/aot 7.0.102
zig 1.zig 1137ms 8.5ms 25.7MB 1103ms 17ms zig 0.11.0-dev.1480+f68d3c63d
csharp 6-m.cs 1221ms 45ms 144.2MB 1960ms 47ms dotnet 7.0.102
csharp 6-m.cs 1658ms 166ms 71.3MB 2560ms 20ms mono 6.12.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 128ms 0.9ms 7.4MB 113ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 6.cs 150ms 4.7ms 41.9MB 187ms 10ms dotnet/aot 7.0.102
csharp 6.cs 237ms 12ms 53.0MB 303ms 23ms mono 6.12.0
csharp 6.cs 279ms 4.6ms 134.3MB 287ms 47ms dotnet 7.0.102

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 45ms 1.1ms 2.8MB 33ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 2.cs 137ms 1.0ms 10.1MB 133ms 0ms dotnet/aot 7.0.102
csharp 2.cs 186ms 0.6ms 25.1MB 170ms 0ms mono 6.12.0
csharp 2.cs 218ms 0.2ms 104.0MB 173ms 20ms dotnet 7.0.102
csharp 1.cs 1292ms 3.5ms 73.4MB 1280ms 13ms dotnet/aot 7.0.102
csharp 1.cs 1726ms 77ms 161.5MB 1663ms 47ms dotnet 7.0.102
csharp 1.cs 3013ms 1.1ms 49.5MB 2973ms 30ms mono 6.12.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 125ms 0.7ms 2.7MB 120ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 2.cs 399ms 3.6ms 10.2MB 390ms 0ms dotnet/aot 7.0.102
csharp 2.cs 437ms 2.9ms 102.1MB 387ms 20ms dotnet 7.0.102
csharp 2.cs 505ms 4.5ms 25.5MB 493ms 0ms mono 6.12.0
csharp 1.cs 3853ms 86ms 76.0MB 3820ms 33ms dotnet/aot 7.0.102
csharp 1.cs 4637ms 55ms 164.4MB 4577ms 43ms dotnet 7.0.102
csharp 1.cs timeout 0.0ms 47.8MB 4957ms 37ms mono 6.12.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 20ms 0.4ms 1.0MB 10ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 2.cs 72ms 2.1ms 10.0MB 70ms 0ms dotnet/aot 7.0.102
csharp 2.cs 106ms 0.5ms 25.3MB 90ms 3ms mono 6.12.0
csharp 2.cs 152ms 3.6ms 103.8MB 103ms 17ms dotnet 7.0.102
csharp 1.cs 2821ms 6.3ms 62.7MB 2793ms 17ms dotnet/aot 7.0.102
csharp 1.cs 3077ms 49ms 152.5MB 2997ms 57ms dotnet 7.0.102
csharp 1.cs 3184ms 3.0ms 31.4MB 3170ms 0ms mono 6.12.0

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 427ms 0.4ms 4.3MB 417ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 2.cs 743ms 8.9ms 164.9MB 663ms 53ms dotnet 7.0.102
csharp 3.cs 3636ms 52ms 112.0MB 3583ms 23ms dotnet 7.0.102
csharp 1.cs 4032ms 70ms 107.8MB 3960ms 17ms dotnet 7.0.102
csharp 3.cs 4533ms 14ms 15.9MB 4530ms 0ms dotnet/aot 7.0.102
csharp 1.cs timeout 0.0ms 14.4MB 4990ms 0ms dotnet/aot 7.0.102
csharp 1.cs timeout 0.0ms 26.8MB 4983ms 0ms mono 6.12.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 20ms 0.7ms 0.9MB 10ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 2.cs 143ms 6.1ms 111.6MB 100ms 17ms dotnet 7.0.102
csharp 3.cs 195ms 3.2ms 15.1MB 190ms 0ms dotnet/aot 7.0.102
csharp 1.cs 236ms 9.3ms 13.0MB 230ms 0ms dotnet/aot 7.0.102
csharp 1.cs 248ms 1.8ms 106.1MB 197ms 17ms dotnet 7.0.102
csharp 3.cs 251ms 2.9ms 108.6MB 203ms 17ms dotnet 7.0.102
csharp 1.cs 836ms 6.0ms 28.7MB 820ms 0ms mono 6.12.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 786ms 7.0ms 362.7MB 683ms 147ms dotnet/aot 7.0.102
csharp 1.cs 842ms 1.2ms 379.9MB 727ms 163ms dotnet/aot 7.0.102
csharp 2.cs 1019ms 3.2ms 468.0MB 840ms 190ms dotnet 7.0.102
csharp 1.cs 1066ms 8.0ms 510.7MB 857ms 230ms dotnet 7.0.102
zig 1.zig 1076ms 10ms 41.1MB 1050ms 7ms zig 0.11.0-dev.1480+f68d3c63d
csharp 1.cs 1697ms 30ms 143.8MB 1993ms 157ms mono 6.12.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 159ms 1.9ms 70.7MB 127ms 30ms dotnet/aot 7.0.102
zig 1.zig 219ms 2.8ms 11.0MB 207ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 1.cs 224ms 9.9ms 199.5MB 147ms 70ms dotnet/aot 7.0.102
csharp 1.cs 305ms 1.9ms 74.1MB 280ms 30ms mono 6.12.0
csharp 1.cs 366ms 4.2ms 270.8MB 250ms 93ms dotnet 7.0.102
csharp 2.cs 389ms 1.3ms 172.5MB 333ms 43ms dotnet 7.0.102

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 303ms 0.7ms 1.0MB 290ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 1.zig 363ms 0.4ms 1.0MB 350ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 9.cs 431ms 4.2ms 102.5MB 383ms 17ms dotnet 7.0.102
csharp 8.cs 495ms 0.3ms 12.0MB 493ms 0ms dotnet/aot 7.0.102
csharp 8.cs 554ms 3.4ms 97.9MB 503ms 27ms dotnet 7.0.102
csharp 8.cs 1136ms 44ms 24.3MB 1120ms 3ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 32ms 0.3ms 1.0MB 20ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 1.zig 40ms 0.8ms 1.0MB 30ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 8.cs 58ms 1.4ms 8.0MB 57ms 0ms dotnet/aot 7.0.102
csharp 9.cs 122ms 3.6ms 100.5MB 73ms 17ms dotnet 7.0.102
csharp 8.cs 129ms 2.1ms 100.2MB 83ms 17ms dotnet 7.0.102
csharp 8.cs 133ms 1.4ms 25.1MB 117ms 3ms mono 6.12.0

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 423ms 3.7ms 6.0MB 413ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 1.zig 624ms 18ms 40.2MB 600ms 10ms zig 0.11.0-dev.1480+f68d3c63d
csharp 2.cs 772ms 9.8ms 21.9MB 760ms 0ms dotnet/aot 7.0.102
csharp 1.cs 850ms 17ms 71.9MB 827ms 17ms dotnet/aot 7.0.102
csharp 1.cs 868ms 21ms 88.4MB 840ms 13ms mono 6.12.0
csharp 2.cs 954ms 1.4ms 109.4MB 907ms 17ms dotnet 7.0.102
csharp 1.cs 1390ms 21ms 157.1MB 1327ms 33ms dotnet 7.0.102
csharp 2.cs 2463ms 28ms 32.3MB 2450ms 0ms mono 6.12.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 95ms 0.1ms 2.2MB 80ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 1.zig 117ms 3.5ms 10.9MB 103ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 1.cs 138ms 5.1ms 29.9MB 137ms 0ms dotnet/aot 7.0.102
csharp 1.cs 183ms 1.5ms 42.5MB 160ms 7ms mono 6.12.0
csharp 2.cs 192ms 2.1ms 15.1MB 187ms 0ms dotnet/aot 7.0.102
csharp 2.cs 289ms 4.7ms 104.7MB 243ms 17ms dotnet 7.0.102
csharp 1.cs 348ms 2.4ms 114.8MB 303ms 17ms dotnet 7.0.102
csharp 2.cs 605ms 2.9ms 25.6MB 590ms 0ms mono 6.12.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 2303ms 0.9ms 2.3MB 2280ms 7ms zig 0.11.0-dev.1480+f68d3c63d
csharp 1.cs 4502ms 7.1ms 76.2MB 4477ms 30ms dotnet/aot 7.0.102
csharp 1.cs 4744ms 13ms 169.7MB 4663ms 110ms dotnet 7.0.102

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 517ms 0.9ms 1.9MB 510ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 1.cs 1070ms 1.7ms 73.7MB 1047ms 17ms dotnet/aot 7.0.102
csharp 1.cs 1186ms 12ms 163.7MB 1173ms 37ms dotnet 7.0.102

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 1062ms 0.9ms 1.3MB 2053ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 2.zig 2061ms 1.2ms 1.0MB 2050ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 3-m.cs 2567ms 42ms 13.8MB 4943ms 3ms dotnet/aot 7.0.102
csharp 3-m.cs 4480ms 103ms 103.0MB 8387ms 27ms dotnet 7.0.102
zig 1.zig 4577ms 0.7ms 1.1MB 4567ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 3.cs timeout 0.0ms 31.1MB 9770ms 7ms mono 6.12.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 276ms 0.9ms 1.1MB 500ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 2.zig 517ms 0.4ms 1.1MB 507ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 3-m.cs 650ms 2.9ms 12.1MB 1230ms 10ms dotnet/aot 7.0.102
zig 1.zig 1148ms 0.7ms 1.1MB 1137ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 3.cs 1434ms 228ms 104.6MB 2077ms 27ms dotnet 7.0.102
csharp 3-m.cs 3100ms 4.6ms 29.8MB 6033ms 10ms mono 6.12.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 84ms 12ms 1.2MB 127ms 0ms zig 0.11.0-dev.1480+f68d3c63d
zig 2.zig 131ms 0.3ms 1.0MB 120ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 3-m.cs 182ms 1.4ms 12.4MB 317ms 3ms dotnet/aot 7.0.102
zig 1.zig 291ms 1.6ms 1.1MB 280ms 0ms zig 0.11.0-dev.1480+f68d3c63d
csharp 3-m.cs 403ms 1.5ms 104.2MB 633ms 27ms dotnet 7.0.102
csharp 3-m.cs 887ms 148ms 29.4MB 1523ms 3ms mono 6.12.0