Skip to content

benchmark: expose google benchmark's intrinsic command-line options #15076

Closed

Description

@jmarantz

Description:

Currently we populate a TCLAP command-line parser with a few options, and use the TCLAP infrastructure to parse the command line early in test/benchmark/main.cc. There are actually a number of google-benchmark options that may be useful, such as --benchmark_report_aggregates_only --benchmark_repetitions=10. See https://android.googlesource.com/platform/external/google-benchmark/+show/refs/heads/master/README.md for details. However, they are not accessible because TCLAP errors out on any command-line options it doesn't recognize.

I think it is sufficient to move the call to ::benchmark::Initialize(&argc, argv); to the first line of main() and then both the Google Benchmark options will be supported, and also the new custom option "skip_expensive_benchmarks". If you do that, then you get this with "benchmark --help":

benchmark [--benchmark_list_tests={true|false}]
          [--benchmark_filter=<regex>]
          [--benchmark_min_time=<min_time>]
          [--benchmark_repetitions=<num_repetitions>]
          [--benchmark_report_aggregates_only={true|false}]
          [--benchmark_display_aggregates_only={true|false}]
          [--benchmark_format=<console|json|csv>]
          [--benchmark_out=<filename>]
          [--benchmark_out_format=<json|console|csv>]
          [--benchmark_color={auto|true|false}]
          [--benchmark_counters_tabular={true|false}]
          [--v=<verbosity>]

So in that case you don't get the help for --skip_expensive_benchmarks. I think it will still work though. An alternative would be to use the absl mechanism for declaring a command-line flag for skip_expensive_benchmarks rather than TCLAP, and then I think "--help" will give you the integrated view.

So there's a few things to sort out here. I think this would be easy to do.

Activity

  1. added
    enhancement
    triage
    beginner
    help wanted
    and removed
    triage
    on Feb 17, 2021
  2. Razdeep commented on Feb 19, 2021

    @Razdeep
    Contributor

    @jmarantz I would like to work on this issue.

  3. mattklein123 commented on Feb 25, 2021

    @mattklein123
    Member

    Fixed by #15133

  4. jmarantz commented on Feb 25, 2021

    @jmarantz
    ContributorAuthor

    This is a great improvement but I don't think it's ideal.

    I think "--help" should give you both skip_expensive_benchmarks and the google benchmark options. Otherwise they are hard to discover. The checked in fix makes all the options work (yay!) but only shows help for skip_expensive_benchmarks.

    IMO the best solution (as described above) is to use the absl command-line flags for everything, then hopefully --help will just work.

  5. self-assigned this
    on Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

beginnerenhancementhelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions