C VS Ruby benchmarks

Current benchmark data was generated on Mon Dec 30 2024, 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.)

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 1.0ms 0.0ms 1.4MB 0ms 0ms zigcc 0.13.0
c 1.c 1.3ms 0.1ms 2.1MB 0ms 0ms gcc 14.2.0
c 1.c 1.4ms 0.2ms 2.1MB 0ms 0ms clang 14.0.0-1ubuntu1.1
ruby 1.rb 39ms 0.5ms 165.1MB 12ms 32ms truffleruby 24.1.1
ruby 1.rb 51ms 1.2ms 13.1MB 38ms 2ms ruby/yjit 3.4.1
ruby 1.rb 53ms 0.7ms 12.9MB 40ms 4ms ruby 3.4.1

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1-m.c 175ms 2.8ms 26.5MB 410ms 10ms gcc 14.2.0
c 1-m.c 303ms 7.0ms 27.7MB 1030ms 30ms clang 14.0.0-1ubuntu1.1

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1-m.c 28ms 1.2ms 12.8MB 63ms 0ms gcc 14.2.0
c 1-m.c 37ms 0.9ms 14.9MB 107ms 3ms clang 14.0.0-1ubuntu1.1

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1-mffi.c 216ms 7.9ms 7.6MB 807ms 3ms clang 14.0.0-1ubuntu1.1
c 1-mffi.c 320ms 45ms 6.6MB 910ms 0ms gcc 14.2.0
c 1-ffi.c 431ms 1.2ms 6.0MB 417ms 0ms zigcc unknown
c 1-mffi.c 432ms 3.3ms 6.0MB 423ms 0ms zigcc unknown
c 1-ffi.c 455ms 4.1ms 6.7MB 440ms 0ms clang 14.0.0-1ubuntu1.1
c 1-ffi.c 540ms 3.5ms 6.8MB 533ms 0ms gcc 14.2.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1-mffi.c 17ms 1.4ms 8.5MB 30ms 0ms clang 14.0.0-1ubuntu1.1
c 1-ffi.c 20ms 0.2ms 3.0MB 10ms 0ms zigcc unknown
c 1-mffi.c 20ms 0.1ms 3.0MB 10ms 0ms zigcc unknown
c 1-ffi.c 22ms 0.4ms 3.6MB 10ms 0ms clang 14.0.0-1ubuntu1.1
c 1-mffi.c 23ms 0.8ms 5.8MB 60ms 0ms gcc 14.2.0
c 1-ffi.c 26ms 1.4ms 3.5MB 13ms 0ms gcc 14.2.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 246ms 1.1ms 1.5MB 233ms 0ms zigcc 0.13.0
c 5.c 298ms 0.5ms 1.5MB 290ms 0ms zigcc 0.13.0
c 8-i.c 300ms 0.7ms 2.1MB 290ms 0ms clang 14.0.0-1ubuntu1.1
c 2.c 309ms 1.2ms 2.3MB 300ms 0ms gcc 14.2.0
c 2.c 311ms 1.6ms 1.5MB 300ms 0ms zigcc 0.13.0
c 5.c 311ms 0.5ms 2.3MB 300ms 0ms gcc 14.2.0
c 5.c 314ms 1.7ms 2.1MB 310ms 0ms clang 14.0.0-1ubuntu1.1
c 2.c 325ms 14ms 2.1MB 313ms 0ms clang 14.0.0-1ubuntu1.1
c 8-i.c 332ms 1.3ms 2.3MB 320ms 0ms gcc 14.2.0
ruby 2.rb 835ms 6.7ms 327.0MB 1073ms 117ms truffleruby 24.1.1
ruby 2.rb timeout 0.0ms 12.9MB 4980ms 3ms ruby 3.4.1
ruby 2.rb timeout 0.0ms 13.6MB 4980ms 3ms ruby/yjit 3.4.1

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 27ms 0.5ms 1.5MB 20ms 0ms zigcc 0.13.0
c 5.c 32ms 0.4ms 1.5MB 20ms 0ms zigcc 0.13.0
c 8-i.c 33ms 0.6ms 2.1MB 23ms 0ms clang 14.0.0-1ubuntu1.1
c 5.c 33ms 0.0ms 2.3MB 27ms 0ms gcc 14.2.0
c 2.c 33ms 0.4ms 2.3MB 23ms 0ms gcc 14.2.0
c 2.c 34ms 0.3ms 1.5MB 27ms 0ms zigcc 0.13.0
c 5.c 34ms 0.5ms 2.1MB 23ms 0ms clang 14.0.0-1ubuntu1.1
c 8-i.c 35ms 0.1ms 2.3MB 27ms 0ms gcc 14.2.0
c 2.c 35ms 1.7ms 2.1MB 23ms 0ms clang 14.0.0-1ubuntu1.1
ruby 2-m.rb 322ms 4.0ms 333.7MB 590ms 100ms truffleruby 24.1.1
ruby 2.rb 1053ms 5.8ms 13.6MB 1037ms 3ms ruby/yjit 3.4.1
ruby 2.rb 2816ms 74ms 12.9MB 2800ms 3ms ruby 3.4.1

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 266ms 8.2ms 40.9MB 250ms 0ms gcc 14.2.0
c 1.c 273ms 3.6ms 40.8MB 257ms 0ms clang 14.0.0-1ubuntu1.1
c 1.c 303ms 15ms 40.3MB 287ms 3ms zigcc 0.13.0
ruby 1.rb timeout 0.0ms 325.4MB 4850ms 133ms ruby 3.4.1
ruby 1.rb timeout 0.0ms 327.1MB 4843ms 133ms ruby/yjit 3.4.1
ruby 1.rb timeout 0.0ms 762.9MB 5063ms 167ms truffleruby 24.1.1

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 50ms 1.3ms 11.5MB 33ms 0ms clang 14.0.0-1ubuntu1.1
c 1.c 53ms 5.0ms 11.6MB 40ms 0ms gcc 14.2.0
c 1.c 60ms 2.8ms 11.0MB 47ms 0ms zigcc 0.13.0
ruby 1-m.rb 1740ms 47ms 486.8MB 2463ms 153ms truffleruby 24.1.1
ruby 1.rb 3441ms 129ms 131.9MB 3357ms 70ms ruby/yjit 3.4.1
ruby 1.rb 4493ms 12ms 131.1MB 4407ms 73ms ruby 3.4.1

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 6-im.c 959ms 3.7ms 4.1MB 3763ms 0ms gcc 14.2.0
c 4-m.c 963ms 1.3ms 4.1MB 3777ms 0ms gcc 14.2.0
c 6-im.c 1014ms 27ms 7.2MB 3937ms 13ms clang 14.0.0-1ubuntu1.1
c 5-im.c 1092ms 4.2ms 4.1MB 4290ms 0ms gcc 14.2.0
c 4-m.c 1118ms 3.5ms 7.3MB 4377ms 3ms clang 14.0.0-1ubuntu1.1
c 5-im.c 1329ms 4.7ms 5.3MB 5207ms 3ms clang 14.0.0-1ubuntu1.1
c 3-m.c 1873ms 45ms 5.3MB 7227ms 20ms clang 14.0.0-1ubuntu1.1
c 3-m.c 1974ms 7.7ms 4.1MB 7773ms 0ms gcc 14.2.0
ruby 4.rb timeout 0.0ms 13.0MB 4980ms 3ms ruby 3.4.1
ruby 4.rb timeout 0.0ms 13.6MB 4980ms 7ms ruby/yjit 3.4.1
ruby 4.rb timeout 0.0ms 467.6MB 5170ms 207ms truffleruby 24.1.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 6-im.c 248ms 1.1ms 4.0MB 947ms 0ms gcc 14.2.0
c 4-m.c 254ms 1.5ms 4.0MB 967ms 0ms gcc 14.2.0
c 6-im.c 259ms 0.3ms 5.3MB 977ms 0ms clang 14.0.0-1ubuntu1.1
c 5-im.c 287ms 5.1ms 4.0MB 1090ms 0ms gcc 14.2.0
c 4-m.c 288ms 0.9ms 5.1MB 1087ms 3ms clang 14.0.0-1ubuntu1.1
c 5-im.c 340ms 1.6ms 7.3MB 1303ms 0ms clang 14.0.0-1ubuntu1.1
c 3-m.c 471ms 13ms 5.4MB 1797ms 3ms clang 14.0.0-1ubuntu1.1
c 3-m.c 511ms 13ms 4.0MB 1970ms 0ms gcc 14.2.0
ruby 4.rb 4492ms 21ms 467.4MB 4820ms 187ms truffleruby 24.1.1
ruby 4.rb timeout 0.0ms 13.0MB 4980ms 3ms ruby 3.4.1
ruby 4.rb timeout 0.0ms 13.6MB 4973ms 13ms ruby/yjit 3.4.1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 6-im.c 72ms 3.3ms 4.0MB 247ms 0ms gcc 14.2.0
c 6-im.c 72ms 1.3ms 7.1MB 247ms 0ms clang 14.0.0-1ubuntu1.1
c 4-m.c 77ms 9.0ms 4.0MB 263ms 0ms gcc 14.2.0
c 4-m.c 80ms 0.5ms 5.1MB 273ms 0ms clang 14.0.0-1ubuntu1.1
c 5-im.c 81ms 2.6ms 4.0MB 287ms 0ms gcc 14.2.0
c 5-im.c 92ms 0.5ms 5.2MB 317ms 3ms clang 14.0.0-1ubuntu1.1
c 3-m.c 129ms 7.0ms 5.1MB 460ms 0ms clang 14.0.0-1ubuntu1.1
c 3-m.c 135ms 1.0ms 4.0MB 500ms 0ms gcc 14.2.0
ruby 4.rb 1289ms 48ms 390.0MB 1640ms 137ms truffleruby 24.1.1
ruby 4.rb timeout 0.0ms 13.0MB 4983ms 7ms ruby 3.4.1
ruby 4.rb timeout 0.0ms 13.9MB 4980ms 3ms ruby/yjit 3.4.1