concat test
This commit is contained in:
parent
7c1911bbda
commit
c577804946
24
concat_test.go
Normal file
24
concat_test.go
Normal file
@ -0,0 +1,24 @@
|
||||
package imageutils
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/png"
|
||||
"io"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkConcat(b *testing.B) {
|
||||
var instance image.Image
|
||||
pixel := SinglePixel{}
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
instance = Concat(instance, pixel, Right)
|
||||
}
|
||||
err := png.Encode(
|
||||
io.Discard,
|
||||
instance,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
2
genprof
2
genprof
@ -1,2 +1,2 @@
|
||||
go test -cpuprofile=profile.out -bench=BenchmarkSinglePixel &&
|
||||
go test -cpuprofile=profile.out -bench=$1 &&
|
||||
go tool pprof -text profile.out
|
||||
|
@ -18,20 +18,6 @@ func Render(img image.Image, rect image.Rectangle) image.Image {
|
||||
return newimg
|
||||
}
|
||||
|
||||
type SinglePixel struct{}
|
||||
|
||||
func (s SinglePixel) At(x, y int) color.Color {
|
||||
return color.White
|
||||
}
|
||||
|
||||
func (s SinglePixel) ColorModel() color.Model {
|
||||
return color.RGBAModel
|
||||
}
|
||||
|
||||
func (s SinglePixel) Bounds() image.Rectangle {
|
||||
return image.Rect(0, 0, 1, 1)
|
||||
}
|
||||
|
||||
func BenchmarkScale(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
err := png.Encode(io.Discard,
|
||||
|
20
util.go
Normal file
20
util.go
Normal file
@ -0,0 +1,20 @@
|
||||
package imageutils
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
type SinglePixel struct{}
|
||||
|
||||
func (s SinglePixel) At(x, y int) color.Color {
|
||||
return color.White
|
||||
}
|
||||
|
||||
func (s SinglePixel) ColorModel() color.Model {
|
||||
return color.RGBAModel
|
||||
}
|
||||
|
||||
func (s SinglePixel) Bounds() image.Rectangle {
|
||||
return image.Rect(0, 0, 1, 1)
|
||||
}
|
Loading…
Reference in New Issue
Block a user