mirror of
https://github.com/ruby/ruby.git
synced 2026-07-30 15:41:06 +08:00
Implements GC fast path for newrange instruction when we do not need to
call <=> method (when either endpoint is nil or both are fixnums).
Benchmark:
def run(max)
i = 0
while i < max
a = i..max
i += 1
end
end
30.times { run(10) }
run(10_000_000)
Result:
Benchmark 1: master
Time (mean ± σ): 221.8 ms ± 5.2 ms [User: 214.4 ms, System: 5.8 ms]
Range (min … max): 216.4 ms … 235.8 ms 13 runs
Benchmark 2: branch
Time (mean ± σ): 62.4 ms ± 1.6 ms [User: 56.0 ms, System: 5.1 ms]
Range (min … max): 60.7 ms … 69.7 ms 46 runs
Summary
branch ran
3.56 ± 0.12 times faster than master