[FR] Do not necessarily print "s" or "/s" for custom counters tagged as rate

Abierto
#1,588 0 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Chaturvediharsh123 ya está trabajando en esto.

Desde el 2/10/2026.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
cpp
Área
performance

Línea de trabajo

Comienza con la lógica de formateo de tasas en src/console_reporter.cc enlazada por el issue y, después, sigue el enum de flags de Counter y cómo se representan los contadores personalizados. El cambio estará completo cuando un contador de tasa que use kHasNoUnit se imprima sin un sufijo "/s" automático, mientras que los demás contadores de tasa conserven su formato actual.

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.
I would like to have a new column in my benchmark report presenting the number of operations per dollar. I have a constant value that I know, which is the cost per second. The calculation I want in that column is given by the formula:

number_of_iterations / (cost_per_second * total_execution_time_in_seconds)

I think I can obtain the number of iterations using the iterations() function in the state object, but I couldn't find a way to recover the total execution time. The only way I found to do that calculation is by adding a new counter with 1 / cost_per_second and tag it as benchmark::Counter::kIsIterationInvariantRate

state.counters["Throughput"] = benchmark::Counter(
   1 / cost_per_second, 
   benchmark::Counter::kIsIterationInvariantRate
);

This will multiply 1 / cost_per_second by number_of_iterations / total_execution_time_in_seconds and will give me the exact value I want. However, since I'm using a kIsRate variant, it will always append "/s" to that value when I print the report in the console. This is wrong. The unit, in this case, would be "OP/$".

Describe the solution you'd like
Implement a new element in the enum kHasNoUnit and don't append the "/s" in case it is in use.

state.counters["Throughput"] = benchmark::Counter(
   1 / cost_per_second, 
   benchmark::Counter::kIsIterationInvariantRate | benchmark::Counter::kHasNoUnit
);

Describe alternatives you've considered
Another option would be to simply enable the user to define a custom unit to the counter. In this case, I would set "OP/$".

Lenguaje dominante
C++
Estrellas
10.5k
Forks
1.8k
Merge medio
2 d 1 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.