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 BENCHMARK_TEMPLATE[12]_CAPTURE, fusion of BENCHMARK_CAPTURE and BENCHMARK_TEMPLATE #1747

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

LebedevRI
Copy link
Collaborator

@LebedevRI LebedevRI commented Jan 29, 2024

Test coverage isn't great, but not worse than the existing one.

You'd think BENCHMARK_CAPTURE would suffice,
but you can't pass func<targs> to it (due to the < and >),
and when passing (func<targs>) we get issues with brackets.
So i'm not sure if we can fully avoid this helper.

That being said, if there is only a single template argument,
BENCHMARK_CAPTURE() works fine if we avoid using function name.

…nd `BENCHMARK_TEMPLATE`

Test coverage isn't great, but not worse than the existing one.

You'd think `BENCHMARK_CAPTURE` would suffice,
but you can't pass `func<targs>` to it (due to the `<` and `>`),
and when passing `(func<targs>)` we get issues with brackets.
So i'm not sure if we can fully avoid this helper.

That being said, if there is only a single template argument,
`BENCHMARK_CAPTURE()` works fine if we avoid using function name.
@@ -1523,7 +1523,7 @@ class Fixture : public internal::Benchmark {
// /* Registers a benchmark named "BM_takes_args/int_string_test` */
// BENCHMARK_CAPTURE(BM_takes_args, int_string_test, 42, std::string("abc"));
#define BENCHMARK_CAPTURE(func, test_case_name, ...) \
BENCHMARK_PRIVATE_DECLARE(func) = \
BENCHMARK_PRIVATE_DECLARE(_benchmark_) = \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sure hope we consider these unique names as internal implementation detail that we can change?

@LebedevRI LebedevRI requested a review from dmah42 January 29, 2024 20:56
@dmah42 dmah42 merged commit e990563 into google:main Jan 30, 2024
80 checks passed
@dmah42
Copy link
Member

dmah42 commented Jan 30, 2024

nice :)

@LebedevRI LebedevRI deleted the benchmark-template-capture branch January 30, 2024 13:05
@LebedevRI
Copy link
Collaborator Author

@dmah42 thank you!

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.

None yet

2 participants