Ruby VS Typescript benchmarks

Current benchmark data was generated on Fri May 20 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 3160ms 31ms 171.7MB 3337ms 503ms deno 1.22.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
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 197ms 59ms 55.7MB 150ms 20ms deno 1.22.0
ruby 1.rb 897ms 6.4ms 292.1MB 740ms 137ms ruby/yjit 3.1.2
ruby 1-m.rb 951ms 78ms 404.6MB 1523ms 130ms truffleruby 22.1.0
ruby 1.rb 976ms 8.7ms 35.5MB 930ms 23ms 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 2039ms 9.8ms 68.3MB 2040ms 37ms deno 1.22.0
ruby 1.rb 3053ms 9.8ms 336.7MB 2847ms 190ms ruby/yjit 3.1.2
ruby 1.rb 3564ms 76ms 80.2MB 3487ms 60ms ruby 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 174ms 2.9ms 44.8MB 157ms 13ms deno 1.22.0
ruby 1.rb 243ms 3.7ms 42.3MB 203ms 23ms ruby 3.1.2
ruby 1.rb 375ms 3.0ms 298.9MB 220ms 137ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 6.rb 2839ms 35ms 295.0MB 2677ms 143ms ruby/yjit 3.1.2
ruby 6.rb 4345ms 16ms 39.8MB 4310ms 17ms ruby 3.1.2
typescript 1.ts 4393ms 38ms 54.1MB 4227ms 153ms deno 1.22.0
ruby 6.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 6.rb 491ms 2.7ms 287.8MB 340ms 133ms ruby/yjit 3.1.2
typescript 1.ts 506ms 61ms 45.4MB 433ms 33ms deno 1.22.0
ruby 6.rb 507ms 8.2ms 31.1MB 483ms 7ms ruby 3.1.2
ruby 6-m.rb 1439ms 22ms 368.9MB 2527ms 140ms truffleruby 22.1.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 20ms 0.8ms 31.7MB 10ms 0ms deno 1.22.0
ruby 1.rb 39ms 1.0ms 134.6MB 20ms 18ms truffleruby 22.1.0
ruby 1.rb 72ms 1.1ms 30.1MB 50ms 10ms ruby 3.1.2
ruby 1.rb 225ms 0.8ms 286.6MB 72ms 138ms 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-m.ts 164ms 4.8ms 65.2MB 260ms 10ms deno 1.22.0
ruby 1.rb 436ms 5.7ms 48.1MB 397ms 20ms ruby 3.1.2
ruby 1.rb 592ms 3.6ms 304.6MB 433ms 140ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 1129ms 20ms 264.6MB 1320ms 80ms deno 1.22.0
ruby 1.rb 3896ms 8.6ms 160.2MB 3783ms 97ms ruby 3.1.2
ruby 1.rb 4051ms 2.5ms 417.8MB 3817ms 220ms ruby/yjit 3.1.2
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 617ms 3.7ms 286.7MB 477ms 120ms ruby/yjit 3.1.2
ruby 1.rb 623ms 13ms 30.2MB 603ms 3ms ruby 3.1.2
typescript 2.ts 732ms 1.6ms 43.4MB 717ms 10ms deno 1.22.0
ruby 1-m.rb 913ms 8.6ms 326.3MB 1430ms 100ms truffleruby 22.1.0
typescript 1.ts 1158ms 2.2ms 44.0MB 1143ms 3ms deno 1.22.0

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 1379ms 4.7ms 286.8MB 1223ms 140ms ruby/yjit 3.1.2
ruby 1-m.rb 1509ms 4.5ms 360.3MB 2183ms 140ms truffleruby 22.1.0
ruby 1.rb 1696ms 22ms 30.3MB 1667ms 13ms ruby 3.1.2
typescript 2.ts 2121ms 7.1ms 49.7MB 2110ms 10ms deno 1.22.0
typescript 1.ts 3401ms 1.9ms 51.5MB 3383ms 7ms deno 1.22.0

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 343ms 4.0ms 30.0MB 313ms 13ms ruby 3.1.2
typescript 2.ts 369ms 1.4ms 37.9MB 353ms 7ms deno 1.22.0
ruby 1.rb 419ms 0.9ms 286.7MB 277ms 130ms ruby/yjit 3.1.2
typescript 1.ts 436ms 50ms 37.6MB 387ms 10ms deno 1.22.0
ruby 1-m.rb 680ms 65ms 309.9MB 1070ms 100ms truffleruby 22.1.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 671ms 2.2ms 91.2MB 677ms 33ms deno 1.22.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
ruby 1.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 1.ts 177ms 1.2ms 57.2MB 173ms 10ms deno 1.22.0
ruby 1-m.rb 3310ms 16ms 583.4MB 6047ms 240ms truffleruby 22.1.0
ruby 1.rb 3946ms 4.7ms 300.9MB 3780ms 147ms ruby/yjit 3.1.2
ruby 1.rb 4797ms 7.7ms 44.4MB 4757ms 23ms ruby 3.1.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 6.ts 683ms 1.3ms 37.7MB 663ms 3ms deno 1.22.0
ruby 2.rb 1338ms 3.0ms 301.9MB 1703ms 93ms truffleruby 22.1.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 99ms 3.3ms 37.6MB 93ms 0ms deno 1.22.0
ruby 2-m.rb 489ms 4.2ms 289.6MB 797ms 83ms truffleruby 22.1.0
ruby 2.rb 2366ms 7.0ms 286.8MB 2220ms 130ms ruby/yjit 3.1.2
ruby 2.rb 3241ms 11ms 30.0MB 3213ms 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.1.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ruby 1.rb 3510ms 27ms 408.6MB 3937ms 150ms truffleruby 22.1.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.1.0
typescript 3.ts timeout 0.0ms 0.0MB 0ms 0ms deno 1.22.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 3.ts 1365ms 10ms 55.2MB 1360ms 40ms deno 1.22.0
ruby 1-m.rb 2095ms 83ms 383.5MB 3883ms 117ms truffleruby 22.1.0
ruby 1.rb 2507ms 16ms 162.6MB 2430ms 57ms ruby 3.1.2
ruby 1.rb 2676ms 44ms 420.8MB 2477ms 183ms 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.1.0
typescript 7.ts timeout 0.0ms 0.0MB 0ms 0ms deno 1.22.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 7.ts 1280ms 1.3ms 34.8MB 1263ms 3ms deno 1.22.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
ruby 4.rb timeout 0.0ms 0.0MB 0ms 0ms truffleruby 22.1.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
typescript 7.ts 345ms 0.8ms 34.9MB 327ms 7ms deno 1.22.0
ruby 4.rb 1862ms 8.4ms 436.8MB 2480ms 127ms truffleruby 22.1.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