From: Nigel Tao Date: Sun, 7 Oct 2012 00:30:47 +0000 (+1100) Subject: image/jpeg: clean up BenchmarkDecode and BenchmarkEncode to not X-Git-Tag: go1.1rc2~2233 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f2444f0bc18d9b3d61d115ac29479d7ff3c4f829;p=gostls13.git image/jpeg: clean up BenchmarkDecode and BenchmarkEncode to not refer to opacity. Those references were copy/pasted from the image/png encoding benchmarks, which cares whether or not the source image is opaque, but the JPEG encoder does not care. R=r CC=golang-dev https://golang.org/cl/6623052 --- diff --git a/src/pkg/image/jpeg/writer_test.go b/src/pkg/image/jpeg/writer_test.go index c070db00ad..90b89a7b0f 100644 --- a/src/pkg/image/jpeg/writer_test.go +++ b/src/pkg/image/jpeg/writer_test.go @@ -171,7 +171,7 @@ func TestWriter(t *testing.T) { } } -func BenchmarkDecodeRGBOpaque(b *testing.B) { +func BenchmarkDecode(b *testing.B) { b.StopTimer() data, err := ioutil.ReadFile("../testdata/video-001.jpeg") if err != nil { @@ -188,24 +188,21 @@ func BenchmarkDecodeRGBOpaque(b *testing.B) { } } -func BenchmarkEncodeRGBOpaque(b *testing.B) { +func BenchmarkEncode(b *testing.B) { b.StopTimer() img := image.NewRGBA(image.Rect(0, 0, 640, 480)) - // Set all pixels to 0xFF alpha to force opaque mode. bo := img.Bounds() rnd := rand.New(rand.NewSource(123)) for y := bo.Min.Y; y < bo.Max.Y; y++ { for x := bo.Min.X; x < bo.Max.X; x++ { - img.Set(x, y, color.RGBA{ + img.SetRGBA(x, y, color.RGBA{ uint8(rnd.Intn(256)), uint8(rnd.Intn(256)), uint8(rnd.Intn(256)), - 255}) + 255, + }) } } - if !img.Opaque() { - b.Fatal("expected image to be opaque") - } b.SetBytes(640 * 480 * 4) b.StartTimer() options := &Options{Quality: 90}