104
func BenchmarkEncodeGray(b *testing.B) {
106
img := image.NewGray(image.Rect(0, 0, 640, 480))
107
b.SetBytes(640 * 480 * 1)
109
for i := 0; i < b.N; i++ {
110
Encode(ioutil.Discard, img)
114
func BenchmarkEncodeNRGBOpaque(b *testing.B) {
116
img := image.NewNRGBA(image.Rect(0, 0, 640, 480))
117
// Set all pixels to 0xFF alpha to force opaque mode.
119
for y := bo.Min.Y; y < bo.Max.Y; y++ {
120
for x := bo.Min.X; x < bo.Max.X; x++ {
121
img.Set(x, y, color.NRGBA{0, 0, 0, 255})
125
b.Fatal("expected image to be opaque")
127
b.SetBytes(640 * 480 * 4)
129
for i := 0; i < b.N; i++ {
130
Encode(ioutil.Discard, img)
134
func BenchmarkEncodeNRGBA(b *testing.B) {
136
img := image.NewNRGBA(image.Rect(0, 0, 640, 480))
138
b.Fatal("expected image not to be opaque")
140
b.SetBytes(640 * 480 * 4)
142
for i := 0; i < b.N; i++ {
143
Encode(ioutil.Discard, img)
104
147
func BenchmarkEncodePaletted(b *testing.B) {
106
149
img := image.NewPaletted(image.Rect(0, 0, 640, 480), color.Palette{
139
182
img := image.NewRGBA(image.Rect(0, 0, 640, 480))
140
183
if img.Opaque() {
141
b.Fatal("expected image to not be opaque")
184
b.Fatal("expected image not to be opaque")
143
186
b.SetBytes(640 * 480 * 4)