Just wanted to check results of running different ruby versions managed by rbenv.
Sample script used from https://ruby-doc.org/stdlib-2.5.0/libdoc/benchmark/rdoc/Benchmark.html
require 'benchmark'
include Benchmark # we need the CAPTION and FORMAT constants
n = 10000000
Benchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x|
tf = x.report("for:") { for i in 1..n; a = "1"; end }
tt = x.report("times:") { n.times do ; a = "1"; end }
tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
[tf+tt+tu, (tf+tt+tu)/3]
end
Laptop: Dell XPS 15" old 2 years
OS: Ubuntu 20.04 updated
Ruby versions / Results
2.2.1 = 0.700070
2.3.0 = 0.511516
2.4.2 = 0.455849
2.5.0 = 0.554192
2.6.4 = 0.489311
2.7.0 = 0.657698
2.7.1 = 0.556575
2.7.2 = 0.556223
3.0.0 = 0.642555