[FR] Ability to register flags for custom Reporters

Abierto
#1,885 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
cpp
Área
cli, devtools

Línea de trabajo

Empieza leyendo los puntos de entrada existentes benchmark::Initialize, benchmark::RunSpecifiedBenchmarks y BenchmarkReporter, junto con la forma en que los flags de línea de comandos seleccionan los reporters integrados. Define cómo se almacenan, seleccionan y construyen los reporters personalizados registrados y, a continuación, verifica que se pueda elegir un reporter personalizado mediante un flag sin pasarlo explícitamente a RunSpecifiedBenchmarks.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
C++
Estrellas
10.5k
Forks
1.8k
Merge medio
1 d 15 h
PR fusionados (30 d)
28

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de google/benchmark

Todos los issues de google/benchmark

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.