Skip to content

Add BENCHMARK_TEMPLATE[12]_CAPTURE, fusion of BENCHMARK_CAPTURE and BENCHMARK_TEMPLATE#1747

Merged
dmah42 merged 1 commit into
google:mainfrom
LebedevRI:benchmark-template-capture
Jan 30, 2024
Merged

Add BENCHMARK_TEMPLATE[12]_CAPTURE, fusion of BENCHMARK_CAPTURE and BENCHMARK_TEMPLATE#1747
dmah42 merged 1 commit into
google:mainfrom
LebedevRI:benchmark-template-capture

Conversation

@LebedevRI

@LebedevRI LebedevRI commented Jan 29, 2024

Copy link
Copy Markdown
Collaborator

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.

@LebedevRI LebedevRI force-pushed the benchmark-template-capture branch from a0f47cc to 986029e Compare January 29, 2024 18:38
…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.
@LebedevRI LebedevRI force-pushed the benchmark-template-capture branch from 986029e to aebd644 Compare January 29, 2024 20:54
// 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
Copy Markdown
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
@dmah42

dmah42 commented Jan 30, 2024

Copy link
Copy Markdown
Member

nice :)

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

Copy link
Copy Markdown
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.

2 participants