Exemple #1
0
// DEBUG: CPU1 - 35ns/op without alpha
//               165ns/op if alpha is also taken into account (with floats)
func BenchmarkConvertWin(b *testing.B) {
	b.StopTimer()
	diameter := int(math.Sqrt(float64(b.N)))
	if diameter > 5000 {
		diameter = 5000
	}
	r := image.Rect(0, 0, diameter, diameter)
	source := getrgba(r)
	target := win.NewDIB(r)
	b.StartTimer()

	convertRGBAtoWin(target, source)

	b.StopTimer()
	if !compareImages(source, target) {
		b.Fail()
	}
}
Exemple #2
0
// DEBUG: CPU1 - 276ns/op
func BenchmarkDrawToWin(b *testing.B) {
	b.StopTimer()
	diameter := int(math.Sqrt(float64(b.N)))
	if diameter > 5000 {
		diameter = 5000
	}
	r := image.Rect(0, 0, diameter, diameter)
	source := getrgba(r)
	target := win.NewDIB(r)
	b.StartTimer()

	draw.Draw(target, target.Bounds(), source, image.ZP, draw.Src)

	b.StopTimer()
	if !compareImages(source, target) {
		b.Fail()
	}
}