rust-itertools / itertools

Extra iterator adaptors, iterator methods, free functions, and macros.
https://docs.rs/itertools/
Apache License 2.0
2.62k stars 298 forks source link

Specialize `Powerset::nth` #924

Closed Philippe-Cholet closed 2 months ago

Philippe-Cholet commented 2 months ago
cargo bench --bench specializations "powerset/nth"

Same allocations for:
powerset/nth/0 [798.27 µs 800.91 µs 803.82 µs] [821.70 µs 822.85 µs 824.01 µs] [+2.3972% +3.7714% +5.6787%]

-50% allocations for:
powerset/nth/1 [794.67 µs 796.80 µs 799.04 µs] [458.11 µs 458.77 µs 459.43 µs] [-42.712% -42.235% -41.642%]

-67% allocations for:
powerset/nth/2 [837.00 µs 838.81 µs 840.64 µs] [342.81 µs 343.53 µs 344.27 µs] [-59.118% -58.982% -58.848%]

-80% allocations for:
powerset/nth/4 [811.66 µs 814.08 µs 816.47 µs] [241.11 µs 241.62 µs 242.14 µs] [-70.888% -70.441% -70.073%]

-89% allocations for:
powerset/nth/8 [806.11 µs 807.74 µs 809.67 µs] [178.03 µs 178.38 µs 178.76 µs] [-77.959% -77.869% -77.772%]

It doesn't follow the decrease in allocations as closely as combinations[_with_replacement] did. ~I think it's due to the reallocations in Combinations::reset~ (EDIT: apparently not).

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.39%. Comparing base (6814180) to head (aaa7f8a). Report is 67 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #924 +/- ## ========================================== + Coverage 94.38% 94.39% +0.01% ========================================== Files 48 48 Lines 6665 6946 +281 ========================================== + Hits 6291 6557 +266 - Misses 374 389 +15 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.