D VS Ruby benchmarks

Current benchmark data was generated on Thu Sep 22 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
d 1.d 3009ms 27ms 75.1MB 3247ms 0ms ldc2 1.30.0
d 1.d 4697ms 26ms 124.4MB 4803ms 20ms dmd 2.100.2
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
d 1.d 260ms 0.9ms 15.1MB 247ms 0ms ldc2 1.30.0
d 1.d 390ms 4.8ms 16.3MB 380ms 0ms dmd 2.100.2
ruby 1-m.rb 893ms 4.8ms 400.8MB 1437ms 140ms truffleruby 22.2.0
ruby 1.rb 909ms 3.9ms 292.0MB 757ms 133ms ruby/yjit 3.1.2
ruby 1.rb 973ms 6.2ms 35.5MB 940ms 17ms 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 3096ms 14ms 336.6MB 2900ms 177ms ruby/yjit 3.1.2
ruby 1.rb 3554ms 6.1ms 80.2MB 3490ms 50ms ruby 3.1.2
d 1.d timeout 0.0ms 0.0MB 0ms 0ms dmd 2.100.2
d 1.d timeout 0.0ms 0.0MB 0ms 0ms ldc2 1.30.0
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 240ms 4.4ms 42.2MB 200ms 20ms ruby 3.1.2
ruby 1.rb 382ms 1.7ms 298.8MB 227ms 143ms ruby/yjit 3.1.2
d 1.d 1328ms 4.7ms 10.2MB 1313ms 0ms ldc2 1.30.0
d 1.d 1640ms 9.4ms 9.4MB 1620ms 7ms dmd 2.100.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 3825ms 4.1ms 8.0MB 3810ms 0ms ldc2 1.30.0
d 1.d 4476ms 0.9ms 8.9MB 4463ms 0ms dmd 2.100.2

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 656ms 1.6ms 7.1MB 643ms 0ms ldc2 1.30.0
d 1.d 811ms 0.8ms 8.5MB 797ms 0ms dmd 2.100.2

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 202ms 0.8ms 28.2MB 183ms 3ms ldc2 1.30.0
d 1.d 770ms 1.1ms 47.8MB 753ms 7ms dmd 2.100.2
ruby 6.rb 2845ms 14ms 296.0MB 2673ms 153ms ruby/yjit 3.1.2
ruby 6.rb 4360ms 38ms 39.4MB 4327ms 20ms 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
d 1.d 24ms 1.2ms 7.9MB 17ms 0ms ldc2 1.30.0
d 1.d 81ms 1.0ms 9.9MB 70ms 0ms dmd 2.100.2
ruby 6.rb 504ms 2.6ms 287.6MB 353ms 137ms ruby/yjit 3.1.2
ruby 6.rb 505ms 3.9ms 31.1MB 477ms 13ms ruby 3.1.2
ruby 6-m.rb 1331ms 21ms 387.2MB 2350ms 107ms truffleruby 22.2.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 2.4ms 0.6ms 2.9MB 0ms 0ms ldc2 1.30.0
d 1.d 2.7ms 0.7ms 4.0MB 0ms 0ms dmd 2.100.2
ruby 1.rb 41ms 1.1ms 145.7MB 22ms 16ms truffleruby 22.2.0
ruby 1.rb 70ms 0.9ms 29.9MB 48ms 10ms ruby 3.1.2
ruby 1.rb 240ms 1.6ms 286.6MB 100ms 124ms ruby/yjit 3.1.2

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 179ms 1.5ms 4.0MB 170ms 0ms ldc2 1.30.0
d 1.d 248ms 3.0ms 5.0MB 237ms 0ms dmd 2.100.2
ruby 1.rb 609ms 6.2ms 30.2MB 580ms 10ms ruby 3.1.2
ruby 1.rb 627ms 4.1ms 286.6MB 487ms 127ms ruby/yjit 3.1.2
ruby 1-m.rb 746ms 6.4ms 314.0MB 1080ms 93ms truffleruby 22.2.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 526ms 2.0ms 4.1MB 513ms 0ms ldc2 1.30.0
d 1.d 727ms 3.8ms 5.0MB 713ms 0ms dmd 2.100.2
ruby 1.rb 1388ms 18ms 286.8MB 1247ms 127ms ruby/yjit 3.1.2
ruby 1.rb 1391ms 3.8ms 339.8MB 1920ms 120ms truffleruby 22.2.0
ruby 1.rb 1675ms 30ms 30.2MB 1650ms 13ms ruby 3.1.2

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 77ms 1.0ms 3.8MB 70ms 0ms ldc2 1.30.0
d 1.d 108ms 0.9ms 4.6MB 100ms 0ms dmd 2.100.2
ruby 1.rb 347ms 5.8ms 29.9MB 327ms 7ms ruby 3.1.2
ruby 1.rb 433ms 1.2ms 286.7MB 290ms 127ms ruby/yjit 3.1.2
ruby 1-m.rb 538ms 7.6ms 297.4MB 823ms 73ms truffleruby 22.2.0

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 574ms 0.6ms 6.8MB 560ms 0ms ldc2 1.30.0
d 1.d 2510ms 1.5ms 7.6MB 2497ms 0ms dmd 2.100.2

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 27ms 0.2ms 2.9MB 20ms 0ms ldc2 1.30.0
d 1.d 107ms 0.6ms 3.5MB 93ms 0ms dmd 2.100.2

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 1407ms 16ms 74.9MB 1460ms 13ms ldc2 1.30.0
d 1.d 2635ms 10ms 153.3MB 2933ms 27ms dmd 2.100.2
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
d 1.d 280ms 9.3ms 38.9MB 267ms 7ms ldc2 1.30.0
d 1.d 542ms 2.3ms 39.8MB 587ms 0ms dmd 2.100.2
ruby 1-m.rb 3161ms 37ms 580.5MB 5767ms 237ms truffleruby 22.2.0
ruby 1.rb 3960ms 18ms 300.9MB 3797ms 143ms ruby/yjit 3.1.2
ruby 1.rb 4792ms 15ms 44.4MB 4750ms 30ms ruby 3.1.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 424ms 0.4ms 1.2MB 410ms 0ms ldc2 1.30.0
d 2.d 435ms 0.2ms 1.2MB 423ms 0ms ldc2 1.30.0
ruby 2.rb 1108ms 5.4ms 317.8MB 1390ms 100ms truffleruby 22.2.0
d 1.d 1533ms 0.2ms 1.9MB 1520ms 0ms dmd 2.100.2
d 2.d 2677ms 1.5ms 2.0MB 2667ms 0ms dmd 2.100.2
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
d 2.d 46ms 0.2ms 1.2MB 40ms 0ms ldc2 1.30.0
d 1.d 46ms 0.7ms 1.2MB 40ms 0ms ldc2 1.30.0
d 1.d 156ms 0.1ms 1.9MB 143ms 0ms dmd 2.100.2
d 2.d 271ms 0.3ms 2.0MB 260ms 0ms dmd 2.100.2
ruby 2-m.rb 421ms 1.4ms 300.5MB 650ms 100ms truffleruby 22.2.0
ruby 2.rb 2353ms 2.0ms 286.7MB 2207ms 123ms ruby/yjit 3.1.2
ruby 2.rb 3241ms 15ms 29.9MB 3217ms 10ms ruby 3.1.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 754ms 16ms 43.3MB 733ms 7ms ldc2 1.30.0
d 1.d 832ms 34ms 74.7MB 807ms 7ms dmd 2.100.2
d 2.d 861ms 1.4ms 48.4MB 837ms 7ms ldc2 1.30.0
d 2.d 1636ms 1.4ms 49.4MB 1613ms 7ms dmd 2.100.2
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
d 1.d 129ms 1.0ms 14.5MB 113ms 0ms ldc2 1.30.0
d 1.d 140ms 1.4ms 24.0MB 120ms 3ms dmd 2.100.2
d 2.d 205ms 0.2ms 14.3MB 190ms 0ms ldc2 1.30.0
d 2.d 408ms 0.8ms 16.0MB 393ms 0ms dmd 2.100.2
ruby 1.rb 3198ms 35ms 463.2MB 3600ms 157ms 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
d 1.d 3412ms 6.5ms 7.9MB 3407ms 17ms ldc2 1.30.0
d 1.d timeout 0.0ms 0.0MB 0ms 0ms dmd 2.100.2
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
d 1.d 807ms 1.8ms 7.8MB 797ms 3ms ldc2 1.30.0
d 1.d 1693ms 8.3ms 8.8MB 1683ms 0ms dmd 2.100.2
ruby 1-m.rb 1925ms 1.4ms 383.9MB 3523ms 147ms truffleruby 22.2.0
ruby 1.rb 2499ms 1.8ms 161.8MB 2413ms 67ms ruby 3.1.2
ruby 1.rb 2661ms 4.8ms 420.8MB 2450ms 193ms ruby/yjit 3.1.2

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d timeout 0.0ms 0.0MB 0ms 0ms dmd 2.100.2
d 1.d timeout 0.0ms 0.0MB 0ms 0ms ldc2 1.30.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 1453ms 4.1ms 3.9MB 1443ms 0ms ldc2 1.30.0
d 1.d 3195ms 3.9ms 5.2MB 3180ms 7ms dmd 2.100.2

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 4595ms 0.9ms 3.8MB 4580ms 0ms ldc2 1.30.0
d 1.d 4782ms 2.0ms 5.0MB 4770ms 0ms dmd 2.100.2
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
d 1.d 1152ms 1.1ms 3.5MB 1140ms 0ms ldc2 1.30.0
d 1.d 1201ms 3.3ms 4.4MB 1187ms 0ms dmd 2.100.2
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
d 1.d 291ms 0.3ms 3.2MB 280ms 0ms ldc2 1.30.0
d 1.d 303ms 0.2ms 4.0MB 290ms 0ms dmd 2.100.2
ruby 4.rb 2456ms 33ms 462.5MB 2987ms 150ms 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