Repository: google/benchmark
File: include/benchmark/benchmark.h (C/C++)

Code before:
  Benchmark* ArgNames(const std::vector<std::string>& names);

  // Equivalent to Ranges({{lo1, hi1}, {lo2, hi2}}).
  // NOTE: This is a legacy C++03 interface provided for compatibility only.
  //   New code should use 'Ranges'.
  Benchmark* RangePair(int64_t lo1, int64_t hi1, int64_t lo2, int64_t hi2) {
    std::vector<std::pair<int64_t, int64_t> > ranges;
    ranges.push_back(std::make_pair(lo1, hi1));
    ranges.push_back(std::make_pair(lo2, hi2));
    return Ranges(ranges);
  }

  // Have "setup" and/or "teardown" invoked once for every benchmark run.
  // If the benchmark is multi-threaded (will run in k threads concurrently),
  // the setup callback will be be invoked exactly once (not k times) before
  // each run with k threads. Time allowing (e.g. for a short benchmark), there
  // may be multiple such runs per benchmark, each run with its own
  // "setup"/"teardown".
  //
  // If the benchmark uses different size groups of threads (e.g. via
  // ThreadRange), the above will be true for each size group.
  //
  // The callback will be passed the number of threads for this benchmark run.
  //
  // The callback must not be NULL or self-deleting.
  Benchmark* Setup(void (*setup)(benchmark::State&));
  Benchmark* Teardown(void (*teardown)(benchmark::State&));

  // Pass this benchmark object to *func, which can customize
  // the benchmark by calling various methods like Arg, Args,
  // Threads, etc.
  Benchmark* Apply(void (*func)(Benchmark* benchmark));

  // Set the range multiplier for non-dense range. If not called, the range
  // multiplier kRangeMultiplier will be used.
  Benchmark* RangeMultiplier(int multiplier);

  // Set the minimum amount of time to use when running this benchmark. This
  // option overrides the `benchmark_min_time` flag.
  // REQUIRES: `t > 0` and `Iterations` has not been called on this benchmark.
  Benchmark* MinTime(double t);

  // Specify the amount of iterations that should be run by this benchmark.
  // REQUIRES: 'n > 0' and `MinTime` has not been called on this benchmark.
  //
  // NOTE: This function should only be used when *exact* iteration control is
  //   needed and never to control or limit how long a benchmark runs, where
  // `--benchmark_min_time=N` or `MinTime(...)` should be used instead.
  Benchmark* Iterations(IterationCount n);

  // Specify the amount of times to repeat this benchmark. This option overrides

Review comment (suggestion):
should the parameter to the setup/teardown methods be `const`?  i can't imagine we want to change the state during setup or teardown.  it should be safe to, but there's a possibility of breaking some implicit invariant if `State` becomes more complicated.

Code after:
  // only argument values will be shown.
  Benchmark* ArgNames(const std::vector<std::string>& names);

  // Equivalent to Ranges({{lo1, hi1}, {lo2, hi2}}).
  // NOTE: This is a legacy C++03 interface provided for compatibility only.
  //   New code should use 'Ranges'.
  Benchmark* RangePair(int64_t lo1, int64_t hi1, int64_t lo2, int64_t hi2) {
    std::vector<std::pair<int64_t, int64_t> > ranges;
    ranges.push_back(std::make_pair(lo1, hi1));
    ranges.push_back(std::make_pair(lo2, hi2));
    return Ranges(ranges);
  }

  // Have "setup" and/or "teardown" invoked once for every benchmark run.
  // If the benchmark is multi-threaded (will run in k threads concurrently),
  // the setup callback will be be invoked exactly once (not k times) before
  // each run with k threads. Time allowing (e.g. for a short benchmark), there
  // may be multiple such runs per benchmark, each run with its own
  // "setup"/"teardown".
  //
  // If the benchmark uses different size groups of threads (e.g. via
  // ThreadRange), the above will be true for each size group.
  //
  // The callback will be passed a State object, which includes the number
  // of threads, thread-index, benchmark arguments, etc.
  //
  // The callback must not be NULL or self-deleting.
  Benchmark* Setup(void (*setup)(const benchmark::State&));
  Benchmark* Teardown(void (*teardown)(const benchmark::State&));

  // Pass this benchmark object to *func, which can customize
  // the benchmark by calling various methods like Arg, Args,
  // Threads, etc.
  Benchmark* Apply(void (*func)(Benchmark* benchmark));

  // Set the range multiplier for non-dense range. If not called, the range
  // multiplier kRangeMultiplier will be used.
  Benchmark* RangeMultiplier(int multiplier);

  // Set the minimum amount of time to use when running this benchmark. This
  // option overrides the `benchmark_min_time` flag.
  // REQUIRES: `t > 0` and `Iterations` has not been called on this benchmark.
  Benchmark* MinTime(double t);

  // Specify the amount of iterations that should be run by this benchmark.
  // REQUIRES: 'n > 0' and `MinTime` has not been called on this benchmark.
  //
  // NOTE: This function should only be used when *exact* iteration control is
  //   needed and never to control or limit how long a benchmark runs, where
  // `--benchmark_min_time=N` or `MinTime(...)` should be used instead.
  Benchmark* Iterations(IterationCount n);