test(wayland): report fresh frames per op in the capture benchmark
- commit
- f2587abc42678fa2877fc292a387bac0eff51dd3
- author
- brice · · 2026-09-30 19:56 UTC
- committer
- brice · · 2026-10-01 02:26 UTC
- parent
- 037ee43
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +5 -1
M internal/adapters/wayland/source_test.go +5 -1
| @@ -437,8 +437,11 @@ func TestCaptureAllocations(t *testing.T) { | |||
| 437 | 437 | require.LessOrEqual(t, avg, float64(allocBudget)) | |
| 438 | 438 | } | |
| 439 | 439 | ||
| 440 | + | // BenchmarkCapture measures Capture in a tight loop. The compositor needs | |
| 441 | + | // longer than the poll to fill a frame, so many calls repeat the last frame; | |
| 442 | + | // fresh-frames/op says how many were new. | |
| 440 | 443 | func BenchmarkCapture(b *testing.B) { | |
| 441 | - | s, _ := newSource(b, testserver.Config{Outputs: []testserver.OutputSpec{{Name: "BENCH", Width: 1920, Height: 1080, Scale: 1}}}) | |
| 444 | + | s, srv := newSource(b, testserver.Config{Outputs: []testserver.OutputSpec{{Name: "BENCH", Width: 1920, Height: 1080, Scale: 1}}}) | |
| 442 | 445 | target := ports.Target{OutputID: firstOutput(b, s).ID} | |
| 443 | 446 | ctx := context.Background() | |
| 444 | 447 | b.ReportAllocs() | |
| @@ -449,6 +452,7 @@ func BenchmarkCapture(b *testing.B) { | |||
| 449 | 452 | b.Fatal(err) | |
| 450 | 453 | } | |
| 451 | 454 | } | |
| 455 | + | b.ReportMetric(float64(srv.Stats().Ready)/float64(b.N), "fresh-frames/op") | |
| 452 | 456 | } | |
| 453 | 457 | ||
| 454 | 458 | // Opt-in: NEFERCAP_WAYLAND_SOCKET names the socket of a disposable headless | |
| @@ -437,8 +437,11 @@ func TestCaptureAllocations(t *testing.T) { | |||||
| 437 | require.LessOrEqual(t, avg, float64(allocBudget)) | 437 | require.LessOrEqual(t, avg, float64(allocBudget)) | ||
| 438 | } | 438 | } | ||
| 439 | 439 | ||||
| 440 | + | // BenchmarkCapture measures Capture in a tight loop. The compositor needs | |||
| 441 | + | // longer than the poll to fill a frame, so many calls repeat the last frame; | |||
| 442 | + | // fresh-frames/op says how many were new. | |||
| 440 | func BenchmarkCapture(b *testing.B) { | 443 | func BenchmarkCapture(b *testing.B) { | ||
| 441 | - | s, _ := newSource(b, testserver.Config{Outputs: []testserver.OutputSpec{{Name: "BENCH", Width: 1920, Height: 1080, Scale: 1}}}) | 444 | + | s, srv := newSource(b, testserver.Config{Outputs: []testserver.OutputSpec{{Name: "BENCH", Width: 1920, Height: 1080, Scale: 1}}}) |
| 442 | target := ports.Target{OutputID: firstOutput(b, s).ID} | 445 | target := ports.Target{OutputID: firstOutput(b, s).ID} | ||
| 443 | ctx := context.Background() | 446 | ctx := context.Background() | ||
| 444 | b.ReportAllocs() | 447 | b.ReportAllocs() | ||
| @@ -449,6 +452,7 @@ func BenchmarkCapture(b *testing.B) { | |||||
| 449 | b.Fatal(err) | 452 | b.Fatal(err) | ||
| 450 | } | 453 | } | ||
| 451 | } | 454 | } | ||
| 455 | + | b.ReportMetric(float64(srv.Stats().Ready)/float64(b.N), "fresh-frames/op") | |||
| 452 | } | 456 | } | ||
| 453 | 457 | ||||
| 454 | // Opt-in: NEFERCAP_WAYLAND_SOCKET names the socket of a disposable headless | 458 | // Opt-in: NEFERCAP_WAYLAND_SOCKET names the socket of a disposable headless | ||