draw optimizations
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package world
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkBuildRenderPlanStageA_Candidates(b *testing.B) {
|
||||
w := NewWorld(600, 600)
|
||||
|
||||
// Make the index/grid available.
|
||||
w.IndexOnViewportChange(1000, 700, 1.0)
|
||||
|
||||
// Populate with enough objects to create duplicates across cells.
|
||||
// Circles and lines create bbox indexing (more duplicates).
|
||||
for i := 0; i < 2000; i++ {
|
||||
_, _ = w.AddPoint(float64(i%600), float64((i*7)%600))
|
||||
}
|
||||
for i := 0; i < 1200; i++ {
|
||||
_, _ = w.AddCircle(float64((i*11)%600), float64((i*13)%600), 8.0)
|
||||
}
|
||||
for i := 0; i < 1200; i++ {
|
||||
x1 := float64((i*3 + 10) % 600)
|
||||
y1 := float64((i*5 + 20) % 600)
|
||||
x2 := float64((i*7 + 400) % 600)
|
||||
y2 := float64((i*11 + 300) % 600)
|
||||
_, _ = w.AddLine(x1, y1, x2, y2)
|
||||
}
|
||||
w.Reindex()
|
||||
|
||||
params := RenderParams{
|
||||
ViewportWidthPx: 1000,
|
||||
ViewportHeightPx: 700,
|
||||
MarginXPx: 250,
|
||||
MarginYPx: 175,
|
||||
CameraXWorldFp: 300 * SCALE,
|
||||
CameraYWorldFp: 300 * SCALE,
|
||||
CameraZoom: 1.0,
|
||||
Options: &RenderOptions{
|
||||
BackgroundColor: color.RGBA{A: 255},
|
||||
},
|
||||
}
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := w.buildRenderPlanStageA(params)
|
||||
if err != nil {
|
||||
b.Fatalf("build plan: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user