Ruby VS C# benchmarks

Current benchmark data was generated on Fri May 20 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 1400ms 22ms 390.6MB 1260ms 180ms dotnet 6.0.300
csharp 1.cs 2295ms 25ms 103.2MB 2610ms 193ms 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.1.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 160ms 4.1ms 44.7MB 143ms 3ms mono 6.12.0
csharp 1.cs 194ms 16ms 93.0MB 140ms 20ms dotnet 6.0.300
ruby 1.rb 897ms 6.4ms 292.1MB 740ms 137ms ruby/yjit 3.1.2
ruby 1-m.rb 951ms 78ms 404.6MB 1523ms 130ms truffleruby 22.1.0
ruby 1.rb 976ms 8.7ms 35.5MB 930ms 23ms 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 3053ms 9.8ms 336.7MB 2847ms 190ms ruby/yjit 3.1.2
ruby 1.rb 3564ms 76ms 80.2MB 3487ms 60ms ruby 3.1.2
csharp 1-m.cs 4355ms 373ms 104.4MB 7393ms 87ms dotnet 6.0.300
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 243ms 3.7ms 42.3MB 203ms 23ms ruby 3.1.2
ruby 1.rb 375ms 3.0ms 298.9MB 220ms 137ms ruby/yjit 3.1.2
csharp 1.cs 410ms 20ms 82.8MB 407ms 47ms dotnet 6.0.300
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 386ms 15ms 89.8MB 553ms 117ms dotnet 6.0.300
csharp 5-m.cs 493ms 9.8ms 59.0MB 813ms 110ms mono 6.12.0
ruby 6.rb 2839ms 35ms 295.0MB 2677ms 143ms ruby/yjit 3.1.2
ruby 6.rb 4345ms 16ms 39.8MB 4310ms 17ms ruby 3.1.2
ruby 6.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5.cs 90ms 15ms 36.1MB 100ms 33ms mono 6.12.0
csharp 5.cs 99ms 9.1ms 45.3MB 90ms 23ms dotnet 6.0.300
ruby 6.rb 491ms 2.7ms 287.8MB 340ms 133ms ruby/yjit 3.1.2
ruby 6.rb 507ms 8.2ms 31.1MB 483ms 7ms ruby 3.1.2
ruby 6-m.rb 1439ms 22ms 368.9MB 2527ms 140ms truffleruby 22.1.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 19ms 0.4ms 24.3MB 10ms 0ms mono 6.12.0
ruby 1.rb 39ms 1.0ms 134.6MB 20ms 18ms truffleruby 22.1.0
csharp 1.cs 50ms 4.7ms 32.9MB 24ms 2ms dotnet 6.0.300
ruby 1.rb 72ms 1.1ms 30.1MB 50ms 10ms ruby 3.1.2
ruby 1.rb 225ms 0.8ms 286.6MB 72ms 138ms 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 350ms 7.5ms 67.9MB 313ms 23ms dotnet 6.0.300
ruby 1.rb 436ms 5.7ms 48.1MB 397ms 20ms ruby 3.1.2
csharp 1.cs 530ms 6.0ms 146.6MB 507ms 53ms dotnet 6.0.300
ruby 1.rb 592ms 3.6ms 304.6MB 433ms 140ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 2029ms 17ms 267.6MB 2117ms 100ms dotnet 6.0.300
csharp 1.cs 3283ms 134ms 761.6MB 3160ms 380ms dotnet 6.0.300
ruby 1.rb 3896ms 8.6ms 160.2MB 3783ms 97ms ruby 3.1.2
ruby 1.rb 4051ms 2.5ms 417.8MB 3817ms 220ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 187ms 1.3ms 25.5MB 170ms 0ms mono 6.12.0
csharp 2.cs 208ms 4.7ms 28.0MB 170ms 0ms dotnet 6.0.300
ruby 1.rb 617ms 3.7ms 286.7MB 477ms 120ms ruby/yjit 3.1.2
ruby 1.rb 623ms 13ms 30.2MB 603ms 3ms ruby 3.1.2
ruby 1-m.rb 913ms 8.6ms 326.3MB 1430ms 100ms truffleruby 22.1.0
csharp 1.cs 1670ms 5.3ms 91.7MB 1620ms 37ms dotnet 6.0.300
csharp 1.cs 3070ms 3.0ms 49.8MB 3023ms 37ms mono 6.12.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 457ms 3.5ms 28.1MB 427ms 3ms dotnet 6.0.300
csharp 2.cs 511ms 13ms 24.4MB 497ms 0ms mono 6.12.0
ruby 1.rb 1379ms 4.7ms 286.8MB 1223ms 140ms ruby/yjit 3.1.2
ruby 1-m.rb 1509ms 4.5ms 360.3MB 2183ms 140ms truffleruby 22.1.0
ruby 1.rb 1696ms 22ms 30.3MB 1667ms 13ms ruby 3.1.2
csharp 1.cs 4722ms 92ms 92.7MB 4683ms 27ms dotnet 6.0.300
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 107ms 1.5ms 27.3MB 93ms 0ms mono 6.12.0
csharp 2.cs 130ms 4.5ms 27.7MB 103ms 0ms dotnet 6.0.300
ruby 1.rb 343ms 4.0ms 30.0MB 313ms 13ms ruby 3.1.2
ruby 1.rb 419ms 0.9ms 286.7MB 277ms 130ms ruby/yjit 3.1.2
ruby 1-m.rb 680ms 65ms 309.9MB 1070ms 100ms truffleruby 22.1.0
csharp 1.cs 3190ms 8.7ms 33.8MB 3163ms 3ms mono 6.12.0
csharp 1.cs 3201ms 7.3ms 73.2MB 3160ms 20ms dotnet 6.0.300

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 908ms 3.1ms 378.4MB 773ms 167ms dotnet 6.0.300
csharp 1.cs 922ms 7.6ms 395.6MB 780ms 173ms dotnet 6.0.300
csharp 1.cs 1729ms 34ms 153.0MB 2073ms 143ms 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.1.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 2.cs 253ms 3.7ms 94.1MB 203ms 30ms dotnet 6.0.300
csharp 1.cs 284ms 3.0ms 183.8MB 197ms 67ms dotnet 6.0.300
csharp 1.cs 315ms 3.6ms 74.8MB 283ms 40ms mono 6.12.0
ruby 1-m.rb 3310ms 16ms 583.4MB 6047ms 240ms truffleruby 22.1.0
ruby 1.rb 3946ms 4.7ms 300.9MB 3780ms 147ms ruby/yjit 3.1.2
ruby 1.rb 4797ms 7.7ms 44.4MB 4757ms 23ms ruby 3.1.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 9.cs 438ms 9.0ms 29.3MB 410ms 0ms dotnet 6.0.300
csharp 8.cs 537ms 3.7ms 29.1MB 503ms 3ms dotnet 6.0.300
csharp 8.cs 1110ms 1.7ms 27.0MB 1097ms 0ms mono 6.12.0
ruby 2.rb 1338ms 3.0ms 301.9MB 1703ms 93ms truffleruby 22.1.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 95ms 4.6ms 29.2MB 67ms 0ms dotnet 6.0.300
csharp 8.cs 101ms 4.9ms 31.2MB 77ms 0ms dotnet 6.0.300
csharp 8.cs 135ms 4.1ms 27.0MB 123ms 0ms mono 6.12.0
ruby 2-m.rb 489ms 4.2ms 289.6MB 797ms 83ms truffleruby 22.1.0
ruby 2.rb 2366ms 7.0ms 286.8MB 2220ms 130ms ruby/yjit 3.1.2
ruby 2.rb 3241ms 11ms 30.0MB 3213ms 10ms ruby 3.1.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 910ms 19ms 88.6MB 880ms 17ms mono 6.12.0
csharp 1.cs 960ms 29ms 87.9MB 910ms 20ms dotnet 6.0.300
csharp 2.cs 1031ms 0.9ms 40.1MB 993ms 7ms dotnet 6.0.300
csharp 2.cs 2587ms 3.8ms 32.5MB 2577ms 0ms 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.1.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 185ms 0.6ms 40.7MB 173ms 3ms mono 6.12.0
csharp 1.cs 187ms 4.3ms 45.9MB 153ms 7ms dotnet 6.0.300
csharp 2.cs 301ms 3.8ms 31.7MB 273ms 0ms dotnet 6.0.300
csharp 2.cs 644ms 0.3ms 25.9MB 630ms 0ms mono 6.12.0
ruby 1.rb 3510ms 27ms 408.6MB 3937ms 150ms truffleruby 22.1.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 timeout 0.0ms 0.0MB 0ms 0ms dotnet 6.0.300
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.1.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 1281ms 9.1ms 90.8MB 1277ms 30ms dotnet 6.0.300
ruby 1-m.rb 2095ms 83ms 383.5MB 3883ms 117ms truffleruby 22.1.0
ruby 1.rb 2507ms 16ms 162.6MB 2430ms 57ms ruby 3.1.2
ruby 1.rb 2676ms 44ms 420.8MB 2477ms 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 2999ms 510ms 30.9MB 5187ms 20ms dotnet 6.0.300
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.1.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 719ms 3.7ms 29.5MB 1297ms 13ms dotnet 6.0.300
csharp 3-m.cs 3181ms 129ms 29.4MB 6040ms 10ms 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.1.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 3-m.cs 235ms 3.5ms 30.1MB 360ms 3ms dotnet 6.0.300
csharp 3-m.cs 805ms 2.5ms 30.0MB 1530ms 3ms mono 6.12.0
ruby 4.rb 1862ms 8.4ms 436.8MB 2480ms 127ms truffleruby 22.1.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