Commit 7166dfe0 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent cd6b2b74
......@@ -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)
}
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment