Ruby VS C# benchmarks

Current benchmark data was generated on Wed Sep 28 2022, 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 1331ms 9.4ms 391.1MB 1237ms 157ms dotnet 6.0.401
csharp 1.cs 2177ms 35ms 102.7MB 2453ms 197ms mono 6.12.0
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 151ms 2.5ms 44.6MB 130ms 7ms mono 6.12.0
csharp 1.cs 184ms 6.7ms 90.9MB 140ms 23ms dotnet 6.0.401
ruby 1-m.rb 876ms 6.5ms 391.6MB 1427ms 120ms truffleruby 22.2.0
ruby 1.rb 901ms 1.2ms 292.0MB 743ms 147ms ruby/yjit 3.1.2
ruby 1.rb 975ms 28ms 35.5MB 947ms 10ms ruby 3.1.2

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 3086ms 135ms 336.7MB 2877ms 193ms ruby/yjit 3.1.2
ruby 1.rb 3557ms 173ms 80.1MB 3480ms 57ms ruby 3.1.2
csharp 1-m.cs 4095ms 60ms 104.8MB 6900ms 57ms dotnet 6.0.401
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 244ms 1.2ms 42.3MB 210ms 20ms ruby 3.1.2
ruby 1.rb 382ms 8.4ms 298.8MB 223ms 140ms ruby/yjit 3.1.2
csharp 1-m.cs 414ms 34ms 88.5MB 643ms 33ms dotnet 6.0.401
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 480ms 11ms 80.2MB 827ms 77ms mono 6.12.0
csharp 5.cs 534ms 47ms 87.3MB 590ms 117ms dotnet 6.0.401
ruby 6.rb 2858ms 22ms 296.0MB 2707ms 133ms ruby/yjit 3.1.2
ruby 6.rb 4371ms 79ms 39.5MB 4343ms 17ms ruby 3.1.2
ruby 6.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 90ms 7.4ms 39.1MB 110ms 27ms mono 6.12.0
csharp 5.cs 143ms 14ms 47.4MB 100ms 20ms dotnet 6.0.401
ruby 6.rb 500ms 2.0ms 287.7MB 340ms 143ms ruby/yjit 3.1.2
ruby 6.rb 508ms 11ms 31.1MB 480ms 10ms ruby 3.1.2
ruby 6-m.rb 1299ms 7.3ms 329.0MB 2303ms 103ms truffleruby 22.2.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 18ms 1.2ms 24.3MB 10ms 0ms mono 6.12.0
ruby 1.rb 40ms 2.2ms 146.9MB 22ms 18ms truffleruby 22.2.0
csharp 1.cs 51ms 1.8ms 29.1MB 20ms 2ms dotnet 6.0.401
ruby 1.rb 70ms 0.7ms 29.9MB 48ms 10ms ruby 3.1.2
ruby 1.rb 233ms 0.5ms 286.6MB 96ms 124ms ruby/yjit 3.1.2

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 359ms 4.0ms 65.8MB 313ms 27ms dotnet 6.0.401
ruby 1.rb 427ms 0.9ms 47.3MB 397ms 13ms ruby 3.1.2
csharp 1.cs 528ms 3.5ms 145.7MB 497ms 53ms dotnet 6.0.401
ruby 1.rb 590ms 2.4ms 305.4MB 437ms 140ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 2028ms 4.5ms 275.5MB 2087ms 107ms dotnet 6.0.401
csharp 1.cs 3220ms 136ms 762.9MB 3243ms 340ms dotnet 6.0.401
ruby 1.rb 3979ms 199ms 162.0MB 3883ms 77ms ruby 3.1.2
ruby 1.rb 4022ms 3.4ms 419.0MB 3823ms 180ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 184ms 0.1ms 25.2MB 170ms 0ms mono 6.12.0
csharp 2.cs 199ms 3.1ms 27.6MB 163ms 7ms dotnet 6.0.401
ruby 1.rb 608ms 8.8ms 30.2MB 583ms 10ms ruby 3.1.2
ruby 1.rb 618ms 2.7ms 286.7MB 470ms 137ms ruby/yjit 3.1.2
ruby 1-m.rb 796ms 85ms 353.7MB 1177ms 83ms truffleruby 22.2.0
csharp 1.cs 1743ms 88ms 89.8MB 1700ms 23ms dotnet 6.0.401
csharp 1.cs 3000ms 7.7ms 49.6MB 2960ms 33ms mono 6.12.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 454ms 1.3ms 28.2MB 430ms 3ms dotnet 6.0.401
csharp 2.cs 506ms 7.8ms 25.0MB 490ms 3ms mono 6.12.0
ruby 1.rb 1376ms 7.7ms 286.7MB 1237ms 123ms ruby/yjit 3.1.2
ruby 1.rb 1392ms 11ms 339.9MB 1927ms 120ms truffleruby 22.2.0
ruby 1.rb 1664ms 3.2ms 30.2MB 1647ms 7ms ruby 3.1.2
csharp 1.cs 4626ms 14ms 90.9MB 4570ms 40ms dotnet 6.0.401
csharp 1.cs timeout 0.0ms 0.0MB 0ms 0ms mono 6.12.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 104ms 1.1ms 25.2MB 100ms 0ms mono 6.12.0
csharp 2.cs 128ms 0.6ms 29.9MB 107ms 0ms dotnet 6.0.401
ruby 1.rb 335ms 4.9ms 29.9MB 320ms 3ms ruby 3.1.2
ruby 1.rb 427ms 1.6ms 286.6MB 283ms 127ms ruby/yjit 3.1.2
ruby 1-m.rb 536ms 8.3ms 301.8MB 823ms 80ms truffleruby 22.2.0
csharp 1.cs 3189ms 11ms 30.6MB 3163ms 0ms mono 6.12.0
csharp 1.cs 3191ms 8.4ms 77.3MB 3143ms 23ms dotnet 6.0.401

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 921ms 4.2ms 391.9MB 793ms 163ms dotnet 6.0.401
csharp 2.cs 927ms 18ms 378.4MB 787ms 173ms dotnet 6.0.401
csharp 1.cs 1675ms 7.1ms 148.6MB 2093ms 110ms mono 6.12.0
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 252ms 2.7ms 94.2MB 203ms 30ms dotnet 6.0.401
csharp 1.cs 291ms 3.1ms 185.8MB 197ms 73ms dotnet 6.0.401
csharp 1.cs 306ms 5.3ms 72.7MB 277ms 27ms mono 6.12.0
ruby 1-m.rb 3188ms 28ms 570.1MB 5863ms 187ms truffleruby 22.2.0
ruby 1.rb 3898ms 7.4ms 300.7MB 3730ms 153ms ruby/yjit 3.1.2
ruby 1.rb 4753ms 18ms 44.3MB 4720ms 17ms ruby 3.1.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 9.cs 404ms 2.6ms 29.3MB 377ms 3ms dotnet 6.0.401
csharp 8.cs 532ms 4.1ms 25.4MB 503ms 3ms dotnet 6.0.401
ruby 2.rb 1099ms 4.0ms 307.0MB 1397ms 73ms truffleruby 22.2.0
csharp 8.cs 1107ms 0.7ms 25.1MB 1090ms 0ms mono 6.12.0
ruby 2.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 2.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 9.cs 91ms 6.8ms 29.4MB 63ms 3ms dotnet 6.0.401
csharp 8.cs 103ms 0.3ms 27.3MB 73ms 0ms dotnet 6.0.401
csharp 8.cs 135ms 5.0ms 25.3MB 123ms 0ms mono 6.12.0
ruby 2-m.rb 424ms 5.3ms 303.8MB 673ms 80ms truffleruby 22.2.0
ruby 2.rb 2352ms 3.8ms 286.7MB 2193ms 140ms ruby/yjit 3.1.2
ruby 2.rb 3236ms 19ms 29.9MB 3217ms 0ms ruby 3.1.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 657ms 54ms 88.1MB 613ms 13ms dotnet 6.0.401
csharp 1.cs 778ms 31ms 86.7MB 757ms 7ms mono 6.12.0
csharp 2.cs 1003ms 12ms 36.1MB 977ms 3ms dotnet 6.0.401
csharp 2.cs 2442ms 17ms 34.4MB 2423ms 7ms mono 6.12.0
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 184ms 9.3ms 47.9MB 147ms 7ms dotnet 6.0.401
csharp 1.cs 192ms 0.4ms 41.1MB 173ms 3ms mono 6.12.0
csharp 2.cs 281ms 2.2ms 31.7MB 247ms 3ms dotnet 6.0.401
csharp 2.cs 604ms 0.8ms 27.7MB 590ms 0ms mono 6.12.0
ruby 1.rb 3222ms 43ms 475.3MB 3633ms 153ms truffleruby 22.2.0
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 4943ms 41ms 94.3MB 4933ms 43ms dotnet 6.0.401
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 1216ms 9.0ms 94.9MB 1203ms 40ms dotnet 6.0.401
ruby 1-m.rb 1915ms 11ms 398.1MB 3513ms 133ms truffleruby 22.2.0
ruby 1.rb 2479ms 4.7ms 162.9MB 2393ms 70ms ruby 3.1.2
ruby 1.rb 2632ms 6.4ms 420.7MB 2430ms 183ms ruby/yjit 3.1.2

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 2677ms 2.3ms 32.6MB 5163ms 10ms dotnet 6.0.401
csharp 3.cs timeout 0.0ms 0.0MB 0ms 0ms mono 6.12.0
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 714ms 1.1ms 30.3MB 1290ms 13ms dotnet 6.0.401
csharp 3-m.cs 3179ms 76ms 27.6MB 6040ms 7ms mono 6.12.0
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 229ms 2.9ms 29.9MB 347ms 10ms dotnet 6.0.401
csharp 3-m.cs 800ms 2.0ms 28.0MB 1520ms 3ms mono 6.12.0
ruby 4.rb 2453ms 17ms 460.5MB 2993ms 143ms truffleruby 22.2.0
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby 3.1.2
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms ruby/yjit 3.1.2