Skip to content

Conversation

@jmr
Copy link
Member

@jmr jmr commented Jan 12, 2026

Move ::benchmark::internal::Benchmark to ::benchmark::Benchmark.

It's a bit odd that the documented way to pass arguments to a benchmark is with benchmark::internal::Benchmark. Make this public instead.

https://github.com/google/benchmark/blob/v1.9.4/docs/user_guide.md#passing-arguments

https://raw.githubusercontent.com/google/benchmark/refs/tags/v1.9.4/docs/user_guide.md#:~:text=void%20CustomArguments(benchmark%3A%3A-,internal%3A%3ABenchmark,-*%20b)%20%7B%0A%20%20for%20(int

Keep ::benchmark::internal::Benchmark as a deprecated forwarding alias. Uses of Benchmark in the internal namespace need to explicitly use ::benchmark::Benchmark to avoid the deprecation warning.

@dmah42
Copy link
Member

dmah42 commented Jan 12, 2026

I like this change a lot, it's always bothered me that we expose "internal". The window failures look like legitimate issues @jmr .

@jmr jmr force-pushed the benchmark-pub branch 2 times, most recently from e145307 to 0e05338 Compare January 12, 2026 13:58
dmah42
dmah42 previously approved these changes Jan 12, 2026
@dmah42
Copy link
Member

dmah42 commented Jan 12, 2026

this looks good, but will users of the library see broken builds if they're using internal? or will it only be an issue if they have -Werror?

@jmr
Copy link
Member Author

jmr commented Jan 12, 2026

this looks good, but will users of the library see broken builds if they're using internal? or will it only be an issue if they have -Werror?

Only with -Werror -Wdeprecated-declarations, -Werror=deprecated-declarations or similar.

@dmah42
Copy link
Member

dmah42 commented Jan 13, 2026

ok, this LGTM, but i'd like a second maintainer to take a look given it's an API change: @LebedevRI

i think we'll need a release after this too.

@jmr
Copy link
Member Author

jmr commented Jan 13, 2026

it's an API change

It's an ABI change, but the old API continues to work.

i think we'll need a release after this too.

Why? Isn't master just whatever is being worked on now?

@dmah42
Copy link
Member

dmah42 commented Jan 13, 2026

only because there's been a few changes since the last release and this is relatively significant. also it's nicer to import internally point releases rather than commit SHAs.

@LebedevRI
Copy link
Collaborator

LebedevRI commented Jan 13, 2026

If i'm quite honest, this looks like a change just for the sake of change.
More actionable feedback:

  1. The internal::-less Benchmark still takes arguments whose types are defined in internal::
  2. (Some but not all?) classes derived from Benchmark are still internal::. Should they be?

@dmah42
Copy link
Member

dmah42 commented Jan 13, 2026

we should probably fix those too, in follow-ups. I agree with the author that we shouldn't have a public API that has the internal namespace as it's a confusing experience. We should reserve internal for things that need to be in the public header but aren't part of the public API.

Comment on lines 1129 to 1133
// Define alias of ThreadRunner factory function type
using threadrunner_factory =
std::function<std::unique_ptr<ThreadRunnerBase>(int)>;

typedef void(Function)(State&);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing typedefs for these

Copy link
Member Author

Choose a reason for hiding this comment

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

Are these intended to be user-facing? Maybe they should go back to internal?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about Function, FunctionBenchmark and such,
but that whole threadrunner_factory thing
is clearly meant to be externally-avaliable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Move ::benchmark::internal::Benchmark to ::benchmark::Benchmark.

It's a bit odd that the documented way to pass arguments to a
benchmark is with `benchmark::internal::Benchmark`.  Make this
public instead.

https://github.com/google/benchmark/blob/v1.9.4/docs/user_guide.md#passing-arguments

https://raw.githubusercontent.com/google/benchmark/refs/tags/v1.9.4/docs/user_guide.md#:~:text=void%20CustomArguments(benchmark%3A%3A-,internal%3A%3ABenchmark,-*%20b)%20%7B%0A%20%20for%20(int

Keep ::benchmark::internal::Benchmark as a deprecated forwarding alias.
Uses of Benchmark in the internal namespace need to explicitly use
::benchmark::Benchmark to avoid the deprecation warning.
Copy link
Collaborator

@LebedevRI LebedevRI left a comment

Choose a reason for hiding this comment

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

I don't see the point, but sure.

@LebedevRI LebedevRI merged commit 90ebbde into google:main Jan 14, 2026
135 of 136 checks passed
@jmr jmr deleted the benchmark-pub branch January 14, 2026 19:44
@jmr
Copy link
Member Author

jmr commented Jan 14, 2026

I don't see the point, but sure.

The main point is that the internal Google benchmark doesn't use internal::Benchmark, so it's simpler to write code that works for both if it's consistent.

Secondarily, if internal doesn't mean anything, I don't know what to think.

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.

3 participants