-
Notifications
You must be signed in to change notification settings - Fork 310
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
Macro bench_specializations
#786
Macro bench_specializations
#786
Conversation
59baaf3
to
50961c6
Compare
50961c6
to
110a0aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Philippe-Cholet, thanks for this. I'm inclined to merge this, but I have some questions:
- There's
$iterator
and$first_its
. When do we use which? Could we unify (and, thus, potentially simplify code)? - (Not directly related to this PR:) What's our general benchmarking story? Are benchmarks to be run within our CI or before we
cargo publish
a new version to ensure we have no regressions?
Please let me know if I you want to amend something or if I should merge this right away.
black_box(x); | ||
}) | ||
})); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also incllude all
(such as the specialization tests)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I listed the currently missing (stable) methods:
Iterator
:
- Depends on
fold
by default:for_each partition reduce max min max_by_key max_by min_by_key min_by
. - Depends on
try_fold
by default:all any find find_map position cmp partial_cmp eq ne lt le gt ge
. - Depends on
try_rfold
by default:rposition
.
DoubleEndedIterator
:
- Depends on
try_rfold
by default:rfind
.
I'm inclined to not add them at the moment as they rely on one of [try_][r]fold
.
Obviously, we can change our mind later.
DoubleEndedIterator | ||
ExactSizeIterator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat idea! Maybe we should do this in specialization tests, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it too.
ExactSizeIterator
might be unnecessary since we are I think unlikely to specialize len
but it was easy to add once DoubleEndedIterator
was added.
@phimuemue I don't know what's "our general benchmarking story". I assume we simply use them to avoid performance regressions (and most likely real improvements) in pull requests like the recent and various I changed the macro syntax a lot before I was satisfied. What do you think? Before merging, I would like @jswrenn to give a little feedback on it as he wrote the initial issue and might have a different idea in mind? Plus, I'm discovering a lot of "criterion" parts here. What do you think about my first comment (copied below)? I think it's decent to assume
|
@phimuemue I'm also a bit unsure about |
110a0aa
to
d1df7bf
Compare
Now that there are no opened PR about "fold" specializations, I moved benchmarks of I should probably take time to create other "specialization benchmarks" to avoid work in future PRs. But it will be another PR though. |
Similar to `nth` benchmark. With this, all iterator method specializations are considered except for methods that rely on `[r]fold/try_[r]fold` by default. We might want to add others later.
e8fd17b
to
25b2cd8
Compare
Related to #766
Macro to be able to benchmark iterator methods.
Currently, there is only one example in the used macro (put none would lead to a compiler failure).
The expression
$iterator
is supposed to be fast, negligeable compared to the rest. Otherwise, we could usebencher.iter_batched(|| { $iterator }, |mut it| { ... }, ...)
.