Swift VS Ruby benchmarks

Current benchmark data was generated on Sun Jun 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
swift 1.swift 2555ms 26ms 53.8MB 2523ms 20ms swift 6.1.2
ruby 1-m.rb 4549ms 73ms 838.0MB 6403ms 490ms truffleruby 24.2.1
ruby 1.rb 4697ms 113ms 110.0MB 4607ms 77ms ruby/yjit 3.4.4
ruby 1.rb timeout 0.0ms 70.4MB 4953ms 37ms ruby 3.4.4

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 232ms 3.0ms 11.9MB 220ms 0ms swift 6.1.2
ruby 1.rb 489ms 7.3ms 20.3MB 463ms 10ms ruby/yjit 3.4.4
ruby 1-m.rb 502ms 12ms 405.6MB 983ms 153ms truffleruby 24.2.1
ruby 1.rb 948ms 7.8ms 19.5MB 927ms 10ms ruby 3.4.4

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2480ms 2.8ms 5.5MB 2470ms 0ms swift 6.1.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 214ms 2.6ms 5.5MB 207ms 0ms swift 6.1.2

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3-m.swift 146ms 1.6ms 21.0MB 433ms 3ms swift 6.1.2
ruby 6.rb 2020ms 7.1ms 23.0MB 1993ms 13ms ruby/yjit 3.4.4
ruby 6-m.rb 2228ms 213ms 408.8MB 5793ms 337ms truffleruby 24.2.1
ruby 6.rb 3691ms 14ms 22.4MB 3667ms 10ms ruby 3.4.4

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 38ms 0.4ms 14.4MB 33ms 0ms swift 6.1.2
ruby 6.rb 255ms 2.3ms 15.2MB 240ms 0ms ruby/yjit 3.4.4
ruby 6.rb 420ms 5.4ms 14.5MB 403ms 0ms ruby 3.4.4
ruby 6-m.rb 729ms 109ms 365.6MB 1803ms 163ms truffleruby 24.2.1

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2.4ms 0.2ms 5.9MB 0ms 0ms swift 6.1.2
ruby 1.rb 34ms 0.5ms 141.5MB 10ms 26ms truffleruby 24.2.1
ruby 1.rb 50ms 1.4ms 12.9MB 38ms 2ms ruby/yjit 3.4.4
ruby 1.rb 51ms 1.7ms 12.8MB 36ms 2ms ruby 3.4.4

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 1326ms 10ms 74.3MB 4847ms 33ms swift 6.1.2

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 249ms 1.6ms 60.1MB 660ms 27ms swift 6.1.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 343ms 1.2ms 10.1MB 333ms 0ms swift 6.1.2
ruby 2.rb 823ms 8.8ms 310.2MB 1070ms 110ms truffleruby 24.2.1
ruby 2.rb timeout 0.0ms 12.8MB 4983ms 3ms ruby 3.4.4
ruby 2.rb timeout 0.0ms 13.5MB 4983ms 3ms ruby/yjit 3.4.4

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 39ms 1.3ms 10.3MB 30ms 0ms swift 6.1.2
ruby 2-m.rb 323ms 5.2ms 325.5MB 593ms 110ms truffleruby 24.2.1
ruby 2.rb 1025ms 6.4ms 13.5MB 1010ms 3ms ruby/yjit 3.4.4
ruby 2.rb 2919ms 94ms 12.8MB 2903ms 3ms ruby 3.4.4

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb timeout 0.0ms 130.3MB 4870ms 113ms ruby 3.4.4
ruby 1.rb timeout 0.0ms 131.1MB 4837ms 147ms ruby/yjit 3.4.4
ruby 1.rb timeout 0.0ms 465.0MB 13420ms 380ms truffleruby 24.2.1
swift 1.swift timeout 0.0ms 7.1MB 4920ms 67ms swift 6.1.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1-m.rb 1723ms 255ms 383.7MB 4550ms 200ms truffleruby 24.2.1
ruby 1.rb 1760ms 71ms 130.8MB 1653ms 93ms ruby/yjit 3.4.4
ruby 1.rb 1813ms 6.5ms 130.4MB 1677ms 123ms ruby 3.4.4
swift 1.swift 1831ms 3.2ms 7.0MB 1813ms 0ms swift 6.1.2