Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use String#chars + Array#map instead of String#each_char + Array#<< #70

Merged
merged 2 commits into from
Dec 1, 2024

Conversation

gonzedge
Copy link
Owner

@gonzedge gonzedge commented Dec 1, 2024

... during Rambling::Trie#create because this benchmark says it is faster (captured as the ips:each_char_shovel_vs_chars_map):

ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23]
Warming up --------------------------------------
    each_char and <<    63.994k i/100ms
           chars map    83.503k i/100ms
Calculating -------------------------------------
    each_char and <<    615.709k (± 5.7%) i/s    (1.62 μs/i) -      3.072M in   5.006314s
           chars map    814.335k (± 2.8%) i/s    (1.23 μs/i) -      4.092M in   5.028563s

Comparison:
           chars map:   814335.0 i/s
    each_char and <<:   615708.6 i/s - 1.32x  slower

Result:

 ==> Creation - `Rambling::Trie.create`
 5 iterations -
-                                5.181516   0.113003   5.294519 (  5.296937)
+                                4.751531   0.114047   4.865578 (  4.866892)

Copy link

codeclimate bot commented Dec 1, 2024

Code Climate has analyzed commit 71d8cb5 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (95% is the threshold).

This pull request will bring the total coverage in the repository to 100.0% (0.0% change).

View more on Code Climate.

@gonzedge gonzedge merged commit 59dce2f into main Dec 1, 2024
31 checks passed
@gonzedge gonzedge deleted the gonzedge/each-char-char-map branch December 1, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant