Swift VS Ruby benchmarks

Current benchmark data was generated on Tue Jul 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 3027ms 21ms 53.8MB 2990ms 20ms swift 6.1.2
ruby 1-m.rb 4407ms 191ms 804.1MB 6390ms 450ms truffleruby 24.2.1
ruby 1.rb 4955ms 35ms 109.4MB 4853ms 87ms ruby/yjit 3.4.4
ruby 1.rb timeout 0.0ms 70.5MB 4940ms 40ms ruby 3.4.4

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 244ms 5.4ms 11.6MB 230ms 0ms swift 6.1.2
ruby 1.rb 505ms 6.5ms 20.3MB 480ms 10ms ruby/yjit 3.4.4
ruby 1-m.rb 570ms 55ms 424.9MB 1133ms 167ms truffleruby 24.2.1
ruby 1.rb 967ms 21ms 19.5MB 943ms 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 2463ms 3.1ms 5.4MB 2450ms 0ms swift 6.1.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 213ms 1.3ms 5.9MB 203ms 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 141ms 1.1ms 20.8MB 400ms 7ms swift 6.1.2
ruby 6.rb 2079ms 63ms 23.0MB 2053ms 10ms ruby/yjit 3.4.4
ruby 6-m.rb 2218ms 75ms 408.9MB 5653ms 337ms truffleruby 24.2.1
ruby 6.rb 3700ms 18ms 22.4MB 3673ms 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.2MB 30ms 0ms swift 6.1.2
ruby 6.rb 257ms 1.5ms 15.2MB 240ms 3ms ruby/yjit 3.4.4
ruby 6.rb 420ms 1.2ms 14.4MB 403ms 7ms ruby 3.4.4
ruby 6-m.rb 848ms 18ms 388.9MB 2133ms 180ms 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.6ms 0.1ms 5.6MB 0ms 0ms swift 6.1.2
ruby 1.rb 35ms 1.1ms 141.3MB 16ms 24ms truffleruby 24.2.1
ruby 1.rb 52ms 0.9ms 12.8MB 40ms 0ms ruby 3.4.4
ruby 1.rb 52ms 1.2ms 12.9MB 40ms 2ms ruby/yjit 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 1599ms 222ms 78.6MB 5027ms 40ms 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 260ms 7.4ms 59.8MB 673ms 30ms swift 6.1.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 350ms 7.2ms 10.3MB 343ms 0ms swift 6.1.2
ruby 2.rb 835ms 11ms 315.3MB 1080ms 117ms 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 4980ms 7ms 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.1ms 10.0MB 30ms 0ms swift 6.1.2
ruby 2-m.rb 323ms 13ms 309.9MB 563ms 123ms truffleruby 24.2.1
ruby 2.rb 1026ms 2.7ms 13.5MB 1007ms 7ms ruby/yjit 3.4.4
ruby 2.rb 2901ms 120ms 12.8MB 2887ms 0ms 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 46.4MB 4923ms 63ms ruby 3.4.4
ruby 1.rb timeout 0.0ms 130.8MB 4903ms 83ms ruby/yjit 3.4.4
ruby 1.rb timeout 0.0ms 451.3MB 13403ms 393ms truffleruby 24.2.1
swift 1.swift timeout 0.0ms 7.3MB 4927ms 63ms swift 6.1.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1-m.rb 1666ms 261ms 414.4MB 4383ms 213ms truffleruby 24.2.1
ruby 1.rb 1783ms 63ms 130.9MB 1673ms 97ms ruby/yjit 3.4.4
ruby 1.rb 1814ms 58ms 130.3MB 1703ms 93ms ruby 3.4.4
swift 1.swift 1866ms 2.8ms 7.0MB 1850ms 3ms swift 6.1.2