Consider using the trivial `id` benchmark on an example output-type value as a baseline or lower measurement sanity bound
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- haskell
- Área
- performance
Línea de trabajo
Comienza trazando cómo se gestionan bench y nf, y luego examina el punto de entrada defaultMain y el enfoque propuesto con Template Haskell. Determina si Criterion puede medir internamente una output-type id baseline y cómo afectaría a las demás mediciones; el trabajo estará terminado cuando haya una decisión concreta sobre su viabilidad y un comportamiento definido para la resta de la baseline o las advertencias cuando las mediciones estén cerca de la baseline.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I just started experimenting with a tiny function that does some bit twiddling (compiled to a handful of instructions, ideally). It looks like
innerLoop :: Word8 -> Word32
Then for testing purposes I have hand-unrolled variants that just do the same operation 4 times, 8 times, etc.
innderLoop8 :: :: (Word8 , Word8 , Word8 , Word8) -> Word32 -- and so on
A test run gives output something like:
innerLoop = 9.37
innerLoop4 = 12.66
innerLoop8 = 17.83
So it looks like there's overhead somewhere that's not from the precise code I'm interested in. Obviously at this scale, that's not unexpected. But I was curious if I could measure this overhead directly, so I added an id benchmark on a value of the expected output type of the functions I was testing:
-- `id` might work too, or maybe some rewriting will happen that we don't want:
, bench "baseline" $ nf (\x-> x) (0 :: Word32)
]
Which gave:
benchmarking baseline
time 9.494 ns (9.471 ns .. 9.519 ns)
1.000 R² (1.000 R² .. 1.000 R²)
mean 9.495 ns (9.464 ns .. 9.536 ns)
std dev 121.5 ps (99.28 ps .. 163.7 ps)
variance introduced by outliers: 15% (moderately inflated)
If I subtract this measured "overhead" from my other measurements (posted above) the results seem sensible; they're both in line with what I'd expect from the compiled code (haven't looked at assembly yet) and the time increases linearly-ish.
I then tried out a baseline benchmark with () like bench "baseline" $ nf (\x-> x) () which was a little faster, suggesting this is measuring the overhead of nf, not just, say, the cost of a function call per se or something:
benchmarking baseline()
time 6.781 ns (6.753 ns .. 6.818 ns)
1.000 R² (0.999 R² .. 1.000 R²)
mean 6.810 ns (6.774 ns .. 6.864 ns)
std dev 141.1 ps (103.7 ps .. 202.2 ps)
variance introduced by outliers: 33% (moderately inflated)
So my proposal: I wonder if it makes sense for criterion to do some or all of:
- for each
benchline demand the user provide an example value of the result type (or use a Default type class or something), and run theidbenchmark on that - use the resulting value as a baseline for the other measurements
- complain when the measured value is too close to the baseline to be of any value (e.g. as in my
innerLoop)
I wonder if it's even possible for criterion to do this internally, i.e. if we can only "accurately" measure this overhead in the way shown above. In that case it would be possible to use Template Haskell in a new defaultMain-style splice but which inserts new baseline stanzas (and then obviously processes the output, combining benchmarks with their baseline).
- Lenguaje dominante
- Haskell
- Estrellas
- 525
- Forks
- 88
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de haskell/criterion
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
-
first benchmark is expensiveAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 48/100
Todos los issues de haskell/criterion
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
haskell/bytestring#730 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
seal-harness/seal-harness#399 ·
Los mantenedores suelen responder en 1 día
-
add previously overlooked rulesAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
fmidue/codeworld-tasks#124 ·
-
allow haskell-src-exts-1.24Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
reflex-frp/reflex#563 ·