mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-03 18:52:16 -04:00
test(artwork): drop the decodeArtwork benchmark
It existed to capture the before/after baseline for the 128->100 thumbnail change, which it has served. As an ongoing guard it is misleading: a 1000x1000 JPEG decode is ~97% of the 15ms it measures, so the two encoders it would be reached for are ~2.6% of the signal. It reported a phantom 2.8% regression for the NRGBA thumbnail change that isolating the scaler disproved. The per-encoder benchmarks in blurhash/ and thumbhash/ cover the part that actually changes.
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
package artwork
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/jpeg"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func benchJPEG(size int) []byte {
|
||||
img := image.NewRGBA(image.Rect(0, 0, size, size))
|
||||
for y := range size {
|
||||
for x := range size {
|
||||
img.SetRGBA(x, y, color.RGBA{
|
||||
R: uint8(255 * x / size), G: uint8(255 * y / size),
|
||||
B: uint8((x + y) * 255 / (2 * size)), A: 255,
|
||||
})
|
||||
}
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
if err := jpeg.Encode(&buf, img, nil); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
// BenchmarkDecodeArtwork measures the whole per-image cost the artwork worker pays.
|
||||
func BenchmarkDecodeArtwork(b *testing.B) {
|
||||
data := benchJPEG(1000)
|
||||
ctx := context.Background()
|
||||
b.ReportAllocs()
|
||||
for b.Loop() {
|
||||
if _, err := decodeArtwork(ctx, "bench", data); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user