Add goroutines to map renderer

This commit is contained in:
2024-08-29 21:12:18 +02:00
parent 696b827a7d
commit 842c41fdca
5 changed files with 160 additions and 62 deletions
+15
View File
@@ -21,6 +21,14 @@ func logProfilingInfo(handleEventsTime, renderTime, scaleTime, frameTime, frameC
fmt.Print("\n")
}
func logMapProfilingInfo(renderTime, scaleTime, frameTime, frameCount uint64) {
floatFrame := float64(frameCount)
fmt.Printf("Average map render time: %f ms\n", float64(renderTime)/floatFrame)
fmt.Printf("Average map scaling time: %f ms\n", float64(scaleTime)/floatFrame)
fmt.Printf("Average full render time: %f ms\n", float64(frameTime)/floatFrame)
fmt.Print("\n")
}
func resetProfilingCounters(handleEventsTime, renderTime, scaleTime, frameTime *uint64, frameCount *uint64) {
*handleEventsTime = 0
*renderTime = 0
@@ -29,6 +37,13 @@ func resetProfilingCounters(handleEventsTime, renderTime, scaleTime, frameTime *
*frameCount = 0
}
func resetMapProfilingCounters(renderTime, scaleTime, frameTime *uint64, frameCount *uint64) {
*renderTime = 0
*scaleTime = 0
*frameTime = 0
*frameCount = 0
}
func enforceFrameRate(frameStart uint64, targetFPS int) {
frameDuration := 1000 / targetFPS
elapsed := sdl.GetTicks64() - frameStart