1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:54:42 -07:00

image/color: add YCbCrToRGB benchmark

Change-Id: I9ba76d5b0861a901415fdceccaf2f5caa2facb7f
Reviewed-on: https://go-review.googlesource.com/21837
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2016-04-11 11:54:07 -07:00
parent cd6b2b7451
commit 7166dfe0c1

View File

@ -171,3 +171,26 @@ func TestPalette(t *testing.T) {
t.Errorf("got %v, want %v", got, want)
}
}
var sinkr, sinkg, sinkb uint8
func BenchmarkYCbCrToRGB(b *testing.B) {
// YCbCrToRGB does saturating arithmetic.
// Low, middle, and high values can take
// different paths through the generated code.
b.Run("0", func(b *testing.B) {
for i := 0; i < b.N; i++ {
sinkr, sinkg, sinkb = YCbCrToRGB(0, 0, 0)
}
})
b.Run("128", func(b *testing.B) {
for i := 0; i < b.N; i++ {
sinkr, sinkg, sinkb = YCbCrToRGB(128, 128, 128)
}
})
b.Run("255", func(b *testing.B) {
for i := 0; i < b.N; i++ {
sinkr, sinkg, sinkb = YCbCrToRGB(255, 255, 255)
}
})
}