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 BoundTupleIterator #4897

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 BoundTupleIterator, and added unittest & benchmarks for these 2 APIs. Here are the benchmark of the optimized nth and nth_back:

On Stable toolchain

With Optimization

tuple_nth               time:   [283.96 ns 286.42 ns 291.01 ns]
tuple_nth_back          time:   [288.92 ns 289.83 ns 291.15 ns]

The default nth and nth_back implementation

tuple_nth               time:   [2.0933 µs 2.0961 µs 2.0992 µs]
tuple_nth_back          time:   [2.0425 µs 2.0445 µs 2.0468 µs]

On nightly toolchain

With Optimization

tuple_nth               time:   [275.54 ns 275.97 ns 276.49 ns]
tuple_nth_back          time:   [315.25 ns 343.92 ns 375.81 ns]

The default nth and nth_back implementation

tuple_nth               time:   [1.9814 µs 1.9846 µs 1.9883 µs]
tuple_nth_back          time:   [2.0314 µs 2.0705 µs 2.1266 µs]

@Owen-CH-Leung Owen-CH-Leung marked this pull request as ready for review February 9, 2025 15:38
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