aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/image/png/writer_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/image/png/writer_test.go')
-rw-r--r--libgo/go/image/png/writer_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/libgo/go/image/png/writer_test.go b/libgo/go/image/png/writer_test.go
index d67a815698f..b1f97b1d7bf 100644
--- a/libgo/go/image/png/writer_test.go
+++ b/libgo/go/image/png/writer_test.go
@@ -130,6 +130,31 @@ func BenchmarkEncodeGray(b *testing.B) {
}
}
+type pool struct {
+ b *EncoderBuffer
+}
+
+func (p *pool) Get() *EncoderBuffer {
+ return p.b
+}
+
+func (p *pool) Put(b *EncoderBuffer) {
+ p.b = b
+}
+
+func BenchmarkEncodeGrayWithBufferPool(b *testing.B) {
+ b.StopTimer()
+ img := image.NewGray(image.Rect(0, 0, 640, 480))
+ e := Encoder{
+ BufferPool: &pool{},
+ }
+ b.SetBytes(640 * 480 * 1)
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ e.Encode(ioutil.Discard, img)
+ }
+}
+
func BenchmarkEncodeNRGBOpaque(b *testing.B) {
b.StopTimer()
img := image.NewNRGBA(image.Rect(0, 0, 640, 480))