C++ VS C# benchmarks

Current benchmark data was generated on Mon Apr 14 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 396ms 7.9ms 2.6MB 1530ms 0ms g++ 11.4.0
cpp 1-im.cpp 405ms 5.0ms 4.0MB 1567ms 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 39ms 0.3ms 2.6MB 130ms 0ms g++ 11.4.0
cpp 1-im.cpp 39ms 0.2ms 3.9MB 130ms 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.4ms 0.2ms 2.3MB 0ms 0ms clang++ 14.0.0-1ubuntu1.1
csharp 1.cs 9.0ms 3.9ms 6.8MB 0ms 0ms dotnet/aot 9.0.203
csharp 1.cs 31ms 0.6ms 21.3MB 20ms 0ms mono 6.12.0
csharp 1.cs 35ms 1.3ms 26.1MB 20ms 2ms dotnet 9.0.203

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 167ms 0.2ms 1.5MB 160ms 0ms g++ 11.4.0
cpp 0-i.cpp 171ms 0.3ms 2.3MB 160ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 1.cpp 314ms 0.6ms 2.3MB 303ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 1.cpp 314ms 1.5ms 1.8MB 310ms 0ms g++ 11.4.0
csharp 9.cs 360ms 2.9ms 27.6MB 340ms 7ms dotnet 9.0.203
csharp 8.cs 371ms 1.0ms 9.9MB 360ms 0ms dotnet/aot 9.0.203
csharp 8.cs 419ms 1.8ms 27.4MB 400ms 3ms dotnet 9.0.203
csharp 8.cs 1254ms 9.8ms 22.8MB 1240ms 0ms 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.6ms 2.3MB 27ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 1.cpp 34ms 0.6ms 1.8MB 30ms 0ms g++ 11.4.0
csharp 8.cs 46ms 1.4ms 9.9MB 30ms 0ms dotnet/aot 9.0.203
csharp 9.cs 93ms 4.5ms 27.6MB 70ms 7ms dotnet 9.0.203
csharp 8.cs 99ms 8.1ms 27.6MB 80ms 3ms dotnet 9.0.203
csharp 8.cs 162ms 0.8ms 20.9MB 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 316ms 7.0ms 78.7MB 300ms 3ms dotnet/aot 9.0.203
csharp 1.cs 340ms 5.0ms 96.2MB 313ms 13ms dotnet 9.0.203
csharp 2.cs 395ms 3.2ms 17.6MB 380ms 0ms dotnet/aot 9.0.203
csharp 2.cs 398ms 8.9ms 35.5MB 377ms 10ms dotnet 9.0.203
cpp 1.cpp 489ms 5.4ms 7.3MB 477ms 0ms g++ 11.4.0
cpp 1.cpp 528ms 1.2ms 7.8MB 520ms 0ms clang++ 14.0.0-1ubuntu1.1
csharp 1.cs 556ms 7.3ms 83.9MB 533ms 10ms mono 6.12.0
csharp 2.cs 1871ms 22ms 31.1MB 1857ms 0ms mono 6.12.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 64ms 0.5ms 24.9MB 50ms 0ms dotnet/aot 9.0.203
csharp 1.cs 96ms 1.4ms 42.5MB 73ms 10ms dotnet 9.0.203
csharp 2.cs 102ms 2.1ms 11.9MB 90ms 0ms dotnet/aot 9.0.203
cpp 1.cpp 120ms 1.2ms 3.6MB 110ms 0ms g++ 11.4.0
csharp 2.cs 128ms 1.1ms 30.0MB 110ms 10ms dotnet 9.0.203
cpp 1.cpp 132ms 1.5ms 4.1MB 120ms 0ms clang++ 14.0.0-1ubuntu1.1
csharp 1.cs 146ms 2.8ms 38.1MB 133ms 0ms mono 6.12.0
csharp 2.cs 483ms 2.6ms 21.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 470ms 3.9ms 3.4MB 1817ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 8-m.cpp 483ms 0.5ms 2.1MB 1883ms 0ms g++ 11.4.0
cpp 6-im.cpp 927ms 14ms 3.5MB 3627ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 6-im.cpp 930ms 9.8ms 2.1MB 3640ms 0ms g++ 11.4.0
csharp 3-m.cs 1860ms 1.8ms 10.4MB 7253ms 10ms dotnet/aot 9.0.203
csharp 3-m.cs 1926ms 4.5ms 29.9MB 7353ms 23ms dotnet 9.0.203
csharp 3-m.cs 4693ms 178ms 25.5MB 17890ms 10ms 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 1.8ms 3.6MB 457ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 8-m.cpp 127ms 1.2ms 2.0MB 477ms 0ms g++ 11.4.0
cpp 6-im.cpp 237ms 0.4ms 3.4MB 903ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 6-im.cpp 239ms 0.7ms 2.0MB 917ms 0ms g++ 11.4.0
csharp 3-m.cs 494ms 33ms 10.5MB 1787ms 3ms dotnet/aot 9.0.203
csharp 3-m.cs 657ms 23ms 30.0MB 1690ms 10ms dotnet 9.0.203
csharp 3-m.cs 1197ms 19ms 27.2MB 4503ms 13ms mono 6.12.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 37ms 1.6ms 3.4MB 110ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 8-m.cpp 39ms 0.2ms 2.0MB 130ms 0ms g++ 11.4.0
cpp 6-im.cpp 65ms 0.1ms 3.5MB 227ms 0ms clang++ 14.0.0-1ubuntu1.1
cpp 6-im.cpp 68ms 0.6ms 2.0MB 243ms 0ms g++ 11.4.0
csharp 3-m.cs 128ms 1.5ms 10.4MB 450ms 0ms dotnet/aot 9.0.203
csharp 3-m.cs 248ms 8.5ms 28.6MB 463ms 10ms dotnet 9.0.203
csharp 3-m.cs 352ms 13ms 24.8MB 1190ms 10ms mono 6.12.0