simple stat

This commit is contained in:
Dmitry Sergeev
2026-08-22 15:44:40 +03:00
parent b03bfba5bd
commit 1f8ca90566
+26 -2
View File
@@ -462,7 +462,7 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
grant := make(chan struct{})
staged := make(chan struct{})
staged := make(chan uint64)
go func() {
for {
@@ -485,7 +485,7 @@ func main() {
vk.CopyToMapped(staging.Mapped, f.Payload)
// fmt.Println("staged", f.Index)
select {
case staged <- struct{}{}:
case staged <- f.Index:
case <-ctx.Done():
return
}
@@ -500,7 +500,14 @@ func main() {
running := true
resized := false
fullscreen := false
var (
lastIndex uint64
dropped uint64
frameCount uint64
lastReport time.Time
)
for running {
frameStart := time.Now()
var event [128]byte
for sdlPollEvent(unsafe.Pointer(&event[0])) {
eventType := *(*uint32)(unsafe.Pointer(&event[0]))
@@ -558,12 +565,29 @@ func main() {
running = false
continue
}
var shownIndex uint64
select {
case <-staged:
case <-ctx.Done():
running = false
continue
}
if lastIndex != 0 && shownIndex > lastIndex {
if g := shownIndex - lastIndex - 1; g > 0 {
dropped += g
}
}
lastIndex = shownIndex
frameCount++
if now := time.Now(); now.Sub(lastReport) >= time.Second {
dt := now.Sub(lastReport).Seconds()
fps := float64(frameCount) / dt
fmt.Printf("fps=%.1f dropped=%d idx=%d frameTime=%.2fms\n",
fps, dropped, shownIndex, float64(now.Sub(frameStart).Microseconds())/1000.0)
frameCount = 0
dropped = 0
lastReport = now
}
// Record: copy staged V210 into device-local buffer, then clear
cmd := vkCommands[0]