`dup`ing an Identity Hash/Set is faster than creating a new one
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 52/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- ruby
- Domain
- performance
Research direction
Start by locating the repository's existing benchmark or idiom entry format, since no target file is named. Use the supplied Benchmark.ips examples for identity Hash and Set, and consider the work complete when the repository records the comparison and its allocation or performance result consistently with its other entries.
Written by the indexing model from the issue text.
Description
It's one less allocation, too :)
| YJIT off | YJIT on | |
|---|---|---|
Set.new.compare_by_identity |
2.571M | 4.260M |
S.dup |
3.014M | 4.999M |
| ∆ | 1.17x | 1.17x |
| YJIT off | YJIT on | |
|---|---|---|
Hash.new.compare_by_identity |
5.643M | 8.208M |
H.dup |
5.988M | 9.014M |
| ∆ | 1.06x | 1.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
x.compare!
end
- Dominant language
- Ruby
- Stars
- 5.7k
- Forks
- 370
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fastruby/fast-ruby
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
All issues in fastruby/fast-ruby
Similar issues
-
SyncEm always forwards a dummy block, so wrapped methods lose their no-block/Enumerator behavior Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
endoflife-date/endoflife.date#11086 ·
-
internal
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Kong/developer.konghq.com#7322 ·
-
bug P2
Difficulty 2/5 1-3 hours Newbie friendliness 88/100