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

Add complexity estimation of iterating over HashSet and HashMap #97215

Merged
merged 1 commit into from
May 20, 2022
Merged

Add complexity estimation of iterating over HashSet and HashMap #97215

merged 1 commit into from
May 20, 2022

Commits on May 20, 2022

  1. Add complexity estimation of iterating over HashSet and HashMap

    It is not obvious (at least for me) that complexity of iteration over hash tables depends on capacity and not length. Especially comparing with other containers like Vec or String. I think, this behaviour is worth mentioning.
    
    I run benchmark which tests iteration time for maps with length 50 and different capacities and get this results:
    ```
    capacity - time
    64       - 203.87 ns
    256      - 351.78 ns
    1024     - 607.87 ns
    4096     - 965.82 ns
    16384    - 3.1188 us
    ```
    
    If you want to dig why it behaves such way, you can look current implementation in [hashbrown code](https://github.com/rust-lang/hashbrown/blob/f3a9f211d06f78c5beb81ac22ea08fdc269e068f/src/raw/mod.rs#L1933).
    
    Benchmarks code would be presented in PR related to this commit.
    AngelicosPhosphoros committed May 20, 2022
    Configuration menu
    Copy the full SHA
    de97d73 View commit details
    Browse the repository at this point in the history