Open monkeynova opened 1 year ago
store state.range(0)
in a local variable and call DoNotOptimize
on that. eg https://github.com/google/benchmark/blob/main/test/donotoptimize_test.cc
I tried that and still get the same warning. (And since the function overload comes from deduction based on the return of RunProblem, I wasn't sure how it could change things)
That is, transforming my code to the following, still gives me the deprecation warning.
void BM_ProblemXXX(benchmark::State& state) {
int64_t range = state.range(0);
for (auto _ : state) {
benchmark::DoNotOptimize(RunProblem(range));
}
}
I tried that and still get the same warning. (And since the function overload comes from deduction based on the return of RunProblem, I wasn't sure how it could change things)
That is, transforming my code to the following, still gives me the deprecation warning.
void BM_ProblemXXX(benchmark::State& state) { int64_t range = state.range(0); for (auto _ : state) { benchmark::DoNotOptimize(RunProblem(range)); } }
@dmah42 meant to say
void BM_ProblemXXX(benchmark::State& state) {
for (auto _ : state) {
int64_t result = RunProblem(state.range(0));
benchmark::DoNotOptimize(result);
}
}
TBH, this deprecation looks rather bogus to me.
I tried that and still get the same warning. (And since the function overload comes from deduction based on the return of RunProblem, I wasn't sure how it could change things) That is, transforming my code to the following, still gives me the deprecation warning.
void BM_ProblemXXX(benchmark::State& state) { int64_t range = state.range(0); for (auto _ : state) { benchmark::DoNotOptimize(RunProblem(range)); } }
@dmah42 meant to say
void BM_ProblemXXX(benchmark::State& state) { for (auto _ : state) { int64_t result = RunProblem(state.range(0)); benchmark::DoNotOptimize(result); } }
TBH, this deprecation looks rather bogus to me.
you should probably pick that back up on the original issue. i thought the issues raised were fairly compelling (it doesn't do what we expect it to do).
That successfully makes the warning go away (yay?). This feels a lot cruftier than the previous code, but it can get where I want to go.
As far as the original bug, I suspect there are some good reasons for the change. I'm mostly looking for good documentation about how not to run into it (getting a human to review my code on github seems less scalable than I might like) and am still hoping that there could be some doc about what this error means, why the deprecation is needed, and how to move my code forward.
Describe the bug I recently updated the version of this repository used by my bazel(isk) WORKSPACE and I started encountering the deprecation warning about the const-ref form of DoNotOptimize. While I appreciate the warning and want to do better, it's unclear to me what I need to do differently to make it go away.
System Which OS, compiler, and compiler version are you using:
To reproduce Steps to reproduce the behavior:
Expected behavior I would like a description (or link to documentation) about what I need to change in that program to be getting ahead of the deprecation.
Additional context BUILD
empty_test.cc