mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
vector/internal/triangulate: Add a benchmark
This commit is contained in:
parent
8c403d81fe
commit
c116481d33
@ -15,6 +15,7 @@
|
||||
package triangulate_test
|
||||
|
||||
import (
|
||||
"math"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@ -302,3 +303,26 @@ func TestTriangulate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var benchmarkPath []Point
|
||||
|
||||
func init() {
|
||||
const (
|
||||
w = 640
|
||||
h = 480
|
||||
)
|
||||
var p []Point
|
||||
for i := 0; i < w; i++ {
|
||||
x := float32(i)
|
||||
y := h/2 + 80*float32(math.Sin(2*math.Pi*float64(i)/40))
|
||||
p = append(p, Point{X: x, Y: y})
|
||||
}
|
||||
p = append(p, Point{w, h}, Point{0, h})
|
||||
benchmarkPath = p
|
||||
}
|
||||
|
||||
func BenchmarkTriangulate(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
Triangulate(benchmarkPath)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user