[FR] Ability to register flags for custom Reporters

Đang mở
#1,885 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
30/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
cpp
Lĩnh vực
cli, devtools

Hướng nghiên cứu

Bắt đầu bằng cách đọc các entry point hiện có là benchmark::Initialize, benchmark::RunSpecifiedBenchmarks và BenchmarkReporter, cùng với cách các flag dòng lệnh chọn các reporter tích hợp sẵn. Xác định cách các reporter tùy chỉnh đã đăng ký được lưu trữ, lựa chọn và khởi tạo, sau đó xác minh rằng có thể chọn một reporter tùy chỉnh bằng flag mà không truyền rõ ràng reporter đó vào RunSpecifiedBenchmarks.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
C++
Star
10.5k
Fork
1.8k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
28

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của google/benchmark

Tất cả issue của google/benchmark

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.