ebiten: Add BenchmarkColorMScale

Updates #1658
This commit is contained in:
Hajime Hoshi 2021-07-27 13:31:34 +09:00
parent bcb30f8595
commit 79e067b0f8

View File

@ -22,8 +22,10 @@ import (
"image/draw"
_ "image/png"
"math"
"math/rand"
"runtime"
"testing"
"time"
. "github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/examples/resources/images"
@ -31,6 +33,10 @@ import (
t "github.com/hajimehoshi/ebiten/v2/internal/testing"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
func skipTooSlowTests(t *testing.T) bool {
if testing.Short() {
t.Skip("skipping test in short mode")
@ -2405,3 +2411,15 @@ func TestImageEvenOdd(t *testing.T) {
}
}
}
// #1658
func BenchmarkColorMScale(b *testing.B) {
r := rand.Float64
dst := NewImage(16, 16)
src := NewImage(16, 16)
for n := 0; n < b.N; n++ {
op := &DrawImageOptions{}
op.ColorM.Scale(r(), r(), r(), r())
dst.DrawImage(src, op)
}
}