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

Optimize nth and nth_back for BoundListIterator #4810

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Owen-CH-Leung
Copy link
Contributor

See #4787

This PR optimizes nth and nth_back for BoundListIterator, and added unittest & benchmarks for these 2 APIs. Here are the benchmark of the optimized nth and nth_back:

With Optimization

list_nth                time:   [293.43 ns 294.83 ns 296.46 ns]
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high severe

list_nth_back           time:   [303.82 ns 307.94 ns 313.12 ns]
Found 9 outliers among 100 measurements (9.00%)

The default nth and nth_back implementation

list_nth                time:   [2.9155 µs 2.9410 µs 2.9742 µs]
                        change: [+903.75% +913.27% +921.36%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) high mild
  3 (3.00%) high severe

list_nth_back           time:   [3.6843 µs 3.6950 µs 3.7053 µs]
                        change: [+1106.5% +1121.1% +1133.2%] (p = 0.00 < 0.05)
                        Performance has regressed.

@davidhewitt
Copy link
Member

Awesome, thanks! Will seek to review soon. I guess we can do the same thing for tuple iteration?

@Owen-CH-Leung Owen-CH-Leung marked this pull request as ready for review December 21, 2024 15:47
@Owen-CH-Leung
Copy link
Contributor Author

Owen-CH-Leung commented Dec 21, 2024

Awesome, thanks! Will seek to review soon. I guess we can do the same thing for tuple iteration?

Yup - I'll file a PR to optimise tuple iterator after the holiday =)

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.

2 participants