Ruby VS Typescript 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
typescript 1.ts 3386ms 187ms 200.3MB 3387ms 530ms deno 1.25.3
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
typescript 1.ts 130ms 1.1ms 51.3MB 123ms 7ms deno 1.25.3
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
typescript 1.ts 2091ms 27ms 71.6MB 2090ms 27ms deno 1.25.3
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
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
typescript 1.ts 202ms 11ms 46.0MB 163ms 7ms deno 1.25.3
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
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 6.rb 2845ms 14ms 296.0MB 2673ms 153ms ruby/yjit 3.1.2
typescript 1.ts 4338ms 41ms 55.4MB 4160ms 157ms deno 1.25.3
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
typescript 1.ts 462ms 5.7ms 47.6MB 443ms 20ms deno 1.25.3
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
typescript 1.ts 22ms 0.5ms 32.8MB 10ms 0ms deno 1.25.3
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

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 146ms 4.7ms 65.8MB 133ms 13ms deno 1.25.3
ruby 1.rb 430ms 1.4ms 49.3MB 397ms 23ms ruby 3.1.2
ruby 1.rb 600ms 1.7ms 305.1MB 437ms 143ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 1142ms 5.7ms 265.5MB 1240ms 80ms deno 1.25.3
ruby 1.rb 3872ms 2.8ms 160.1MB 3780ms 73ms ruby 3.1.2
ruby 1.rb 4140ms 173ms 418.9MB 3917ms 207ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.2.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
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
typescript 2.ts 693ms 34ms 45.5MB 687ms 3ms deno 1.25.3
ruby 1-m.rb 746ms 6.4ms 314.0MB 1080ms 93ms truffleruby 22.2.0
typescript 1.ts 1091ms 2.3ms 45.4MB 1080ms 7ms deno 1.25.3

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
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
typescript 2.ts 1943ms 11ms 53.2MB 1927ms 13ms deno 1.25.3
typescript 1.ts 3202ms 2.6ms 51.7MB 3183ms 7ms deno 1.25.3

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 2.ts 339ms 2.5ms 40.5MB 333ms 0ms deno 1.25.3
ruby 1.rb 347ms 5.8ms 29.9MB 327ms 7ms ruby 3.1.2
typescript 1.ts 370ms 0.3ms 37.7MB 357ms 3ms deno 1.25.3
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

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 649ms 3.4ms 90.5MB 667ms 30ms deno 1.25.3
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
typescript 1.ts 166ms 1.1ms 59.8MB 170ms 17ms deno 1.25.3
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
typescript 6.ts 630ms 0.8ms 38.6MB 617ms 7ms deno 1.25.3
ruby 2.rb 1108ms 5.4ms 317.8MB 1390ms 100ms truffleruby 22.2.0
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
typescript 6.ts 91ms 1.3ms 36.2MB 77ms 7ms deno 1.25.3
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
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
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
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
typescript 3.ts timeout 0.0ms 0.0MB 0ms 0ms deno 1.25.3

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 3.ts 1526ms 2.8ms 57.7MB 1503ms 90ms deno 1.25.3
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

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
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
typescript 7.ts timeout 0.0ms 0.0MB 0ms 0ms deno 1.25.3

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 7.ts 1279ms 2.0ms 38.5MB 1270ms 3ms deno 1.25.3
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
typescript 7.ts 345ms 1.5ms 36.1MB 330ms 7ms deno 1.25.3
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