[FR] Ability to register flags for custom Reporters

オープン
#1,885 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
cli, devtools

調査の方向性

まず、既存のエントリポイントである benchmark::Initialize、benchmark::RunSpecifiedBenchmarks、BenchmarkReporter と、コマンドラインフラグによって組み込み reporter が選択される仕組みを読みます。登録されたカスタム reporter がどのように格納、選択、構築されるかを定義し、その後、RunSpecifiedBenchmarks に明示的に渡さなくても、フラグによってカスタム reporter を選択できることを確認します。

索引モデルが issue の本文から書いたものです。

説明

Is your feature request related to a problem? Please describe.
If I create a custom BenchmarkReporter, I also have to instantiate it and pass it to the RunSpecifiedBenchmarks function.

int main(int argc, char** argv) {
    benchmark::Initialize(&argc, argv);
    
    BenchmarkReporter* reporter = new FooReporter();
    benchmark::RunSpecifiedBenchmarks(&reporter);
    benchmark::Shutdown();   
}

Describe the solution you'd like
I would like to be able to easily configure a flag for my reporter such as --benchmark_format=foo.

int main(int argc, char** argv) {
    benchmark::Initialize(&argc, argv);
    benchmark::RegisterReporter("foo", [](){ return new FooReporter()})
    benchmark::RunSpecifiedBenchmarks();
    benchmark::Shutdown();
}

Describe alternatives you've considered

  • I currently proxy to the default reporter while intercepting the Run results in my custom reporter, so mine always runs on top of the default behavior.
  • have considered adding arg parsing to main() but that is more convoluted.

Additional context

  • I am interested in adding a custom reporter that asserts that the run results fall within some target performance threshold. I want to be able to optionally select this reporter at runtime with a flag. Built in support for assertions on a given threshold would be a welcome alternative.
  • side note: it would be great to have an overload for ::benchmark::BenchmarkReporter::Run::GetAdjustedRealTime() that accepts a time unit.
主要言語
C++
スター
10.5k
フォーク
1.8k
平均マージ
1日 15時間
マージ済み PR(30日)
28

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google/benchmark のほかの issue

google/benchmark の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。