Skip to content

[BUG] Empty benchmarks cause endless loops #1962

@krzikalla

Description

@krzikalla

Describe the bug

void MyBenchmark(benchmark::State& state)
{
  if (!global_condition)
  {
    return;
  }
  for (auto _ : state)
  {
    ...
  }
}

The above benchmark causes an endless loop in BenchmarkRunner::DoOneRepetition in the current version, if global_condition == false.
I can only tell, that in version 1.5.x such benchmarks were simply ignored (not even output was generated for those).

Expected behavior
I'd like to have the behavior of version 1.5.x: in case of a premature return (i.e. i.iters==0) just ignore the benchmark.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions