Crystal VS Ruby benchmarks

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

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 1295ms 34ms 64.0MB 1273ms 10ms crystal 1.15.1
ruby 1-m.rb 4767ms 126ms 811.9MB 6707ms 477ms truffleruby 24.2.0
ruby 1.rb 4863ms 1.8ms 109.4MB 4763ms 83ms ruby/yjit 3.4.2
ruby 1.rb timeout 0.0ms 70.1MB 4940ms 43ms ruby 3.4.2

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 107ms 2.5ms 10.9MB 93ms 0ms crystal 1.15.1
ruby 1.rb 508ms 33ms 20.3MB 483ms 10ms ruby/yjit 3.4.2
ruby 1-m.rb 555ms 69ms 418.8MB 1097ms 167ms truffleruby 24.2.0
ruby 1.rb 928ms 2.7ms 19.6MB 903ms 10ms ruby 3.4.2

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 1270ms 70ms 19.6MB 1200ms 53ms crystal 1.15.1
ruby 1.rb 1459ms 16ms 63.8MB 1383ms 60ms ruby/yjit 3.4.2
ruby 1.rb 1869ms 36ms 63.1MB 1790ms 63ms ruby 3.4.2
ruby 1.rb timeout 0.0ms 344.5MB 4627ms 1523ms truffleruby 24.2.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 72ms 1.4ms 7.0MB 50ms 10ms crystal 1.15.1
ruby 1.rb 158ms 1.9ms 25.6MB 127ms 20ms ruby/yjit 3.4.2
ruby 1.rb 188ms 3.4ms 25.1MB 157ms 20ms ruby 3.4.2
ruby 1.rb timeout 0.0ms 346.9MB 4623ms 1517ms truffleruby 24.2.0

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 60ms 1.5ms 6.5MB 43ms 3ms crystal 1.15.1

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 22ms 0.5ms 5.0MB 10ms 0ms crystal 1.15.1

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 2504ms 1.5ms 2.8MB 2497ms 0ms crystal 1.15.1

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 207ms 1.1ms 2.8MB 200ms 0ms crystal 1.15.1

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 2.cr 556ms 1.6ms 3.4MB 453ms 90ms crystal 1.15.1
crystal 1.cr 697ms 1.0ms 14.4MB 580ms 103ms crystal 1.15.1
ruby 6.rb 2077ms 33ms 23.0MB 2053ms 10ms ruby/yjit 3.4.2
ruby 6-m.rb 2154ms 27ms 419.9MB 5600ms 347ms truffleruby 24.2.0
ruby 6.rb 3878ms 66ms 22.5MB 3853ms 13ms ruby 3.4.2

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 2.cr 60ms 1.1ms 3.5MB 43ms 7ms crystal 1.15.1
crystal 1.cr 75ms 1.3ms 4.8MB 53ms 7ms crystal 1.15.1
ruby 6.rb 265ms 3.1ms 15.0MB 247ms 7ms ruby/yjit 3.4.2
ruby 6.rb 439ms 2.9ms 14.5MB 420ms 3ms ruby 3.4.2
ruby 6-m.rb 812ms 40ms 382.1MB 2017ms 183ms truffleruby 24.2.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 1.9ms 0.2ms 2.8MB 0ms 0ms crystal 1.15.1
ruby 1.rb 35ms 0.3ms 139.0MB 12ms 24ms truffleruby 24.2.0
ruby 1.rb 53ms 1.0ms 13.1MB 40ms 2ms ruby/yjit 3.4.2
ruby 1.rb 54ms 1.4ms 12.9MB 40ms 2ms ruby 3.4.2

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 2178ms 337ms 255.0MB 320ms 493ms crystal 1.15.1

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 1254ms 106ms 59.5MB 33ms 83ms crystal 1.15.1

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 0-unsafe.cr 36ms 1.5ms 2.9MB 30ms 0ms crystal 1.15.1
crystal 1.cr 65ms 1.9ms 2.9MB 57ms 0ms crystal 1.15.1
ruby 1.rb 331ms 1.9ms 13.5MB 313ms 3ms ruby/yjit 3.4.2
ruby 1.rb 541ms 20ms 13.0MB 527ms 3ms ruby 3.4.2
ruby 1-m.rb 654ms 36ms 370.3MB 1150ms 157ms truffleruby 24.2.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 0-unsafe.cr 99ms 0.6ms 2.9MB 90ms 0ms crystal 1.15.1
crystal 1.cr 185ms 2.9ms 2.9MB 173ms 0ms crystal 1.15.1
ruby 1.rb 876ms 8.2ms 13.5MB 857ms 7ms ruby/yjit 3.4.2
ruby 1-m.rb 1234ms 21ms 404.6MB 1727ms 163ms truffleruby 24.2.0
ruby 1.rb 1479ms 10ms 13.0MB 1457ms 10ms ruby 3.4.2

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 0-unsafe.cr 18ms 0.5ms 2.9MB 10ms 0ms crystal 1.15.1
crystal 1.cr 31ms 1.5ms 2.9MB 20ms 0ms crystal 1.15.1
ruby 1.rb 192ms 1.5ms 13.5MB 170ms 7ms ruby/yjit 3.4.2
ruby 1.rb 292ms 3.4ms 12.9MB 277ms 0ms ruby 3.4.2
ruby 1-m.rb 512ms 30ms 361.1MB 973ms 137ms truffleruby 24.2.0

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 314ms 1.6ms 9.2MB 300ms 0ms crystal 1.15.1

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 18ms 0.2ms 6.4MB 10ms 0ms crystal 1.15.1

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 880ms 9.8ms 64.0MB 860ms 7ms crystal 1.15.1
ruby 1-m.rb 4430ms 469ms 527.4MB 11217ms 380ms truffleruby 24.2.0
ruby 1.rb timeout 0.0ms 93.6MB 4933ms 50ms ruby 3.4.2
ruby 1.rb timeout 0.0ms 94.8MB 4940ms 50ms ruby/yjit 3.4.2

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 164ms 2.8ms 22.1MB 147ms 0ms crystal 1.15.1
ruby 1-m.rb 1938ms 44ms 591.3MB 5030ms 250ms truffleruby 24.2.0
ruby 1.rb 3421ms 15ms 38.3MB 3377ms 30ms ruby/yjit 3.4.2
ruby 1.rb 4437ms 12ms 37.8MB 4397ms 27ms ruby 3.4.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 2.cr 345ms 1.0ms 3.3MB 337ms 0ms crystal 1.15.1
crystal 1.cr 346ms 1.2ms 3.3MB 333ms 0ms crystal 1.15.1
ruby 2.rb 827ms 10ms 306.8MB 1060ms 120ms truffleruby 24.2.0
ruby 2.rb timeout 0.0ms 12.9MB 4980ms 7ms ruby 3.4.2
ruby 2.rb timeout 0.0ms 13.5MB 4980ms 7ms ruby/yjit 3.4.2

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 2.cr 38ms 1.0ms 3.1MB 30ms 0ms crystal 1.15.1
crystal 1.cr 39ms 1.6ms 3.1MB 30ms 0ms crystal 1.15.1
ruby 2-m.rb 312ms 17ms 309.9MB 547ms 110ms truffleruby 24.2.0
ruby 2.rb 1069ms 6.2ms 13.5MB 1050ms 7ms ruby/yjit 3.4.2
ruby 2.rb 2781ms 57ms 12.9MB 2763ms 7ms ruby 3.4.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 2.cr 305ms 5.0ms 8.1MB 293ms 0ms crystal 1.15.1
crystal 1.cr 425ms 1.3ms 42.3MB 410ms 0ms crystal 1.15.1
ruby 1.rb timeout 0.0ms 325.4MB 4843ms 140ms ruby 3.4.2
ruby 1.rb timeout 0.0ms 327.0MB 4850ms 137ms ruby/yjit 3.4.2
ruby 1.rb timeout 0.0ms 695.1MB 5063ms 153ms truffleruby 24.2.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 2.cr 77ms 1.5ms 4.4MB 67ms 0ms crystal 1.15.1
crystal 1.cr 91ms 3.5ms 13.0MB 83ms 0ms crystal 1.15.1
ruby 1-m.rb 1704ms 22ms 482.3MB 2477ms 170ms truffleruby 24.2.0
ruby 1.rb 3396ms 18ms 131.8MB 3303ms 80ms ruby/yjit 3.4.2
ruby 1.rb 4463ms 12ms 131.1MB 4370ms 77ms ruby 3.4.2

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 1938ms 39ms 6.1MB 1910ms 13ms crystal 1.15.1
ruby 1.rb timeout 0.0ms 46.5MB 4930ms 60ms ruby 3.4.2
ruby 1.rb timeout 0.0ms 47.1MB 4923ms 60ms ruby/yjit 3.4.2
ruby 1.rb timeout 0.0ms 443.3MB 13133ms 447ms truffleruby 24.2.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 472ms 18ms 5.0MB 457ms 0ms crystal 1.15.1
ruby 1-m.rb 1605ms 209ms 383.3MB 4227ms 207ms truffleruby 24.2.0
ruby 1.rb 1696ms 3.3ms 46.1MB 1657ms 27ms ruby 3.4.2
ruby 1.rb 1784ms 9.6ms 127.6MB 1637ms 133ms ruby/yjit 3.4.2

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 3796ms 8.1ms 4.5MB 3787ms 0ms crystal 1.15.1
ruby 4.rb timeout 0.0ms 12.9MB 4987ms 0ms ruby 3.4.2
ruby 4.rb timeout 0.0ms 13.5MB 4983ms 3ms ruby/yjit 3.4.2
ruby 4.rb timeout 0.0ms 425.1MB 5170ms 247ms truffleruby 24.2.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 953ms 3.3ms 4.3MB 940ms 0ms crystal 1.15.1
ruby 4.rb 4858ms 56ms 417.3MB 5143ms 210ms truffleruby 24.2.0
ruby 4.rb timeout 0.0ms 12.9MB 4983ms 7ms ruby 3.4.2
ruby 4.rb timeout 0.0ms 13.5MB 4980ms 7ms ruby/yjit 3.4.2

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 242ms 2.7ms 3.8MB 230ms 0ms crystal 1.15.1
ruby 4.rb 1459ms 49ms 378.8MB 1800ms 147ms truffleruby 24.2.0
ruby 4.rb timeout 0.0ms 13.0MB 4983ms 0ms ruby 3.4.2
ruby 4.rb timeout 0.0ms 13.8MB 4980ms 3ms ruby/yjit 3.4.2