You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
duping an Identity Hash/Set is faster than creating a new one #230
YJIT off YJIT on Set.new.compare_by_identity 2.571M 4.260M S.dup3.014M4.999M
∆ 1.17x1.17x
YJIT off YJIT on Hash.new.compare_by_identity 5.643M 8.208M H.dup5.988M9.014M
∆ 1.06x1.09x
S = Set.new.compare_by_identity.freeze
H = Hash.new.compare_by_identity.freeze
Benchmark.ips do |x|
x.config(time: 10)
x.report(".new.compare_by_identity") do |times|
i = 0
while (i += 1) <= times
S.dup
end
end
x.report(".dup ") do |times|
i = 0
while (i += 1) <= times
Set.new.compare_by_identity
end
end
x.compare!
end
Benchmark.ips do |x|
x.config(time: 10)
x.report(".new.compare_by_identity") do |times|
i = 0
while (i += 1) <= times
H.dup
end
end
x.report(".dup ") do |times|
i = 0
while (i += 1) <= times
Hash.new.compare_by_identity
end
end
Activity
JuanVqz commentedon Mar 7, 2025
@amomchilov could you please opne a PR?
BigwWinner commentedon Aug 12, 2026