github.com/jmigpin/editor@v1.6.0/util/imageutil/misc_test.go (about) 1 package imageutil 2 3 import ( 4 "image" 5 "image/color" 6 "image/draw" 7 "testing" 8 ) 9 10 var drawRect = image.Rect(0, 0, 400, 400) 11 12 func BenchmarkFillRect1(b *testing.B) { 13 img := image.NewRGBA(drawRect) 14 bounds := img.Bounds() 15 b.ResetTimer() 16 for i := 0; i < b.N; i++ { 17 FillRectangle(img, bounds, color.White) 18 } 19 } 20 func BenchmarkFillRect2(b *testing.B) { 21 img := NewBGRA(&drawRect) 22 bounds := img.Bounds() 23 b.ResetTimer() 24 for i := 0; i < b.N; i++ { 25 FillRectangle(img, bounds, color.White) 26 } 27 } 28 func BenchmarkDrawBGRA(b *testing.B) { 29 img := NewBGRA(&drawRect) 30 bounds := img.Bounds() 31 b.ResetTimer() 32 for i := 0; i < b.N; i++ { 33 src := image.NewUniform(color.White) 34 draw.Draw(img, bounds, src, image.Point{}, draw.Src) 35 } 36 }