C++ VS C# benchmarks

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

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1-im.cpp 400ms 5.5ms 2.6MB 1540ms 0ms g++ 11.4.0
cpp 1-im.cpp 409ms 4.1ms 4.0MB 1590ms 0ms clang++ 14.0.0-1ubuntu1.1

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1-im.cpp 41ms 1.5ms 2.6MB 133ms 0ms g++ 11.4.0
cpp 1-im.cpp 42ms 0.4ms 4.0MB 140ms 0ms clang++ 14.0.0-1ubuntu1.1

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1.cpp 1.1ms 0.1ms 1.4MB 0ms 0ms g++ 11.4.0
cpp 1.cpp 1.5ms 0.1ms 2.3MB 0ms 0ms clang++ 14.0.0-1ubuntu1.1
csharp 1.cs 8.7ms 2.7ms 9.4MB 0ms 0ms dotnet/aot 9.0.202
csharp 1.cs 32ms 0.6ms 21.6MB 20ms 0ms mono 6.12.0
csharp 1.cs 36ms 1.2ms 26.1MB 20ms 6ms dotnet 9.0.202

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 167ms 0.1ms 1.5MB 160ms 0ms g++ 11.4.0
cpp 0-i.cpp 171ms 0.5ms 2.3MB 160ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 1.cpp 315ms 0.8ms 2.3MB 307ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 1.cpp 316ms 0.4ms 1.8MB 307ms 0ms g++ 11.4.0
csharp 9.cs 364ms 3.9ms 27.8MB 340ms 7ms dotnet 9.0.202
csharp 8.cs 372ms 2.5ms 9.9MB 357ms 0ms dotnet/aot 9.0.202
csharp 8.cs 422ms 2.6ms 27.5MB 400ms 10ms dotnet 9.0.202
csharp 8.cs 1256ms 5.3ms 22.3MB 1240ms 3ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 19ms 0.1ms 1.5MB 10ms 0ms g++ 11.4.0
cpp 0-i.cpp 19ms 0.2ms 2.3MB 10ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 1.cpp 34ms 0.7ms 1.9MB 30ms 0ms g++ 11.4.0
cpp 1.cpp 34ms 0.7ms 2.3MB 30ms 0ms clang++ 14.0.0-1ubuntu1.1
csharp 8.cs 47ms 0.7ms 9.8MB 30ms 0ms dotnet/aot 9.0.202
csharp 8.cs 96ms 1.3ms 27.5MB 80ms 10ms dotnet 9.0.202
csharp 9.cs 97ms 4.6ms 27.8MB 73ms 10ms dotnet 9.0.202
csharp 8.cs 165ms 1.2ms 20.8MB 150ms 0ms mono 6.12.0

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 350ms 3.6ms 78.7MB 327ms 10ms dotnet/aot 9.0.202
csharp 1.cs 399ms 20ms 96.2MB 373ms 17ms dotnet 9.0.202
csharp 2.cs 401ms 3.8ms 35.7MB 380ms 10ms dotnet 9.0.202
csharp 2.cs 425ms 3.0ms 17.4MB 413ms 0ms dotnet/aot 9.0.202
cpp 1.cpp 485ms 2.1ms 7.3MB 477ms 0ms g++ 11.4.0
cpp 1.cpp 531ms 3.5ms 7.8MB 523ms 0ms clang++ 14.0.0-1ubuntu1.1
csharp 1.cs 564ms 2.7ms 83.9MB 543ms 10ms mono 6.12.0
csharp 2.cs 1867ms 2.9ms 29.4MB 1850ms 0ms mono 6.12.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 69ms 1.7ms 24.8MB 50ms 0ms dotnet/aot 9.0.202
csharp 1.cs 107ms 5.9ms 42.4MB 87ms 10ms dotnet 9.0.202
csharp 2.cs 112ms 3.0ms 11.8MB 97ms 0ms dotnet/aot 9.0.202
cpp 1.cpp 119ms 0.4ms 3.6MB 110ms 0ms g++ 11.4.0
csharp 2.cs 131ms 2.0ms 29.9MB 110ms 13ms dotnet 9.0.202
cpp 1.cpp 133ms 1.4ms 4.1MB 123ms 0ms clang++ 14.0.0-1ubuntu1.1
csharp 1.cs 143ms 0.4ms 38.5MB 130ms 0ms mono 6.12.0
csharp 2.cs 486ms 4.3ms 23.1MB 470ms 0ms mono 6.12.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 474ms 9.5ms 3.5MB 1827ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 8-m.cpp 484ms 1.5ms 2.1MB 1883ms 0ms g++ 11.4.0
cpp 6-im.cpp 927ms 9.1ms 2.1MB 3633ms 0ms g++ 11.4.0
cpp 6-im.cpp 928ms 16ms 3.6MB 3630ms 0ms clang++ 14.0.0-1ubuntu1.1
csharp 3-m.cs 1878ms 31ms 10.4MB 7237ms 7ms dotnet/aot 9.0.202
csharp 3-m.cs 2004ms 130ms 29.9MB 7250ms 13ms dotnet 9.0.202
csharp 3-m.cs 4769ms 182ms 27.6MB 18443ms 23ms mono 6.12.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 124ms 0.6ms 3.4MB 460ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 8-m.cpp 130ms 0.6ms 2.0MB 490ms 0ms g++ 11.4.0
cpp 6-im.cpp 238ms 0.5ms 3.4MB 903ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 6-im.cpp 240ms 2.0ms 2.1MB 917ms 0ms g++ 11.4.0
csharp 3-m.cs 476ms 2.3ms 10.3MB 1813ms 3ms dotnet/aot 9.0.202
csharp 3-m.cs 532ms 2.2ms 29.9MB 1877ms 13ms dotnet 9.0.202
csharp 3-m.cs 1261ms 106ms 27.4MB 4513ms 7ms mono 6.12.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 40ms 0.2ms 2.0MB 130ms 0ms g++ 11.4.0
cpp 8-m.cpp 41ms 9.9ms 3.4MB 120ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 6-im.cpp 65ms 0.7ms 3.4MB 230ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 6-im.cpp 67ms 0.4ms 2.1MB 240ms 0ms g++ 11.4.0
csharp 3-m.cs 128ms 0.9ms 10.3MB 447ms 3ms dotnet/aot 9.0.202
csharp 3-m.cs 178ms 0.4ms 28.5MB 500ms 13ms dotnet 9.0.202
csharp 3-m.cs 352ms 1.3ms 25.5MB 1173ms 10ms mono 6.12.0