test(performance): measure warmed layout and batch buffers
- commit
- 69d5b14955e830459e97231595f885ccce19a7ea
- author
- brice · · 2026-09-30 04:23 UTC
- parent
- c1d1834
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +9 -1
M internal/layout/paint_bench_test.go +4 -0
| @@ -53,7 +53,11 @@ func BenchmarkPaint(b *testing.B) { | |||
| 53 | 53 | ||
| 54 | 54 | func BenchmarkLayoutPaintTree(b *testing.B) { | |
| 55 | 55 | root, opts := paintFixture(b, 100) | |
| 56 | + | if _, err := Layout(root, opts); err != nil { | |
| 57 | + | b.Fatal(err) | |
| 58 | + | } | |
| 56 | 59 | b.ReportAllocs() | |
| 60 | + | b.ResetTimer() | |
| 57 | 61 | for i := 0; i < b.N; i++ { | |
| 58 | 62 | if _, err := Layout(root, opts); err != nil { | |
| 59 | 63 | b.Fatal(err) | |
| @@ -53,7 +53,11 @@ func BenchmarkPaint(b *testing.B) { | |||||
| 53 | 53 | ||||
| 54 | func BenchmarkLayoutPaintTree(b *testing.B) { | 54 | func BenchmarkLayoutPaintTree(b *testing.B) { | ||
| 55 | root, opts := paintFixture(b, 100) | 55 | root, opts := paintFixture(b, 100) | ||
| 56 | + | if _, err := Layout(root, opts); err != nil { | |||
| 57 | + | b.Fatal(err) | |||
| 58 | + | } | |||
| 56 | b.ReportAllocs() | 59 | b.ReportAllocs() | ||
| 60 | + | b.ResetTimer() | |||
| 57 | for i := 0; i < b.N; i++ { | 61 | for i := 0; i < b.N; i++ { | ||
| 58 | if _, err := Layout(root, opts); err != nil { | 62 | if _, err := Layout(root, opts); err != nil { | ||
| 59 | b.Fatal(err) | 63 | b.Fatal(err) | ||
M internal/render/instances_bench_test.go +4 -0
| @@ -31,6 +31,7 @@ func listFixture(n int) Frame { | |||
| 31 | 31 | func BenchmarkListBatches(b *testing.B) { | |
| 32 | 32 | frame := listFixture(2000) | |
| 33 | 33 | b.ReportAllocs() | |
| 34 | + | b.ResetTimer() | |
| 34 | 35 | for i := 0; i < b.N; i++ { | |
| 35 | 36 | instances, batches, stats := ListBatches(frame) | |
| 36 | 37 | if len(instances) != 2000 || len(batches) == 0 || len(stats.Skipped) != 0 { | |
| @@ -42,7 +43,10 @@ func BenchmarkListBatches(b *testing.B) { | |||
| 42 | 43 | func BenchmarkListBufferReuse(b *testing.B) { | |
| 43 | 44 | frame := listFixture(2000) | |
| 44 | 45 | var buf ListBuffer | |
| 46 | + | buf.List(frame) | |
| 47 | + | buf.Release() | |
| 45 | 48 | b.ReportAllocs() | |
| 49 | + | b.ResetTimer() | |
| 46 | 50 | for i := 0; i < b.N; i++ { | |
| 47 | 51 | instances, batches, stats := buf.List(frame) | |
| 48 | 52 | if len(instances) != 2000 || len(batches) == 0 || len(stats.Skipped) != 0 { | |
| @@ -31,6 +31,7 @@ func listFixture(n int) Frame { | |||||
| 31 | func BenchmarkListBatches(b *testing.B) { | 31 | func BenchmarkListBatches(b *testing.B) { | ||
| 32 | frame := listFixture(2000) | 32 | frame := listFixture(2000) | ||
| 33 | b.ReportAllocs() | 33 | b.ReportAllocs() | ||
| 34 | + | b.ResetTimer() | |||
| 34 | for i := 0; i < b.N; i++ { | 35 | for i := 0; i < b.N; i++ { | ||
| 35 | instances, batches, stats := ListBatches(frame) | 36 | instances, batches, stats := ListBatches(frame) | ||
| 36 | if len(instances) != 2000 || len(batches) == 0 || len(stats.Skipped) != 0 { | 37 | if len(instances) != 2000 || len(batches) == 0 || len(stats.Skipped) != 0 { | ||
| @@ -42,7 +43,10 @@ func BenchmarkListBatches(b *testing.B) { | |||||
| 42 | func BenchmarkListBufferReuse(b *testing.B) { | 43 | func BenchmarkListBufferReuse(b *testing.B) { | ||
| 43 | frame := listFixture(2000) | 44 | frame := listFixture(2000) | ||
| 44 | var buf ListBuffer | 45 | var buf ListBuffer | ||
| 46 | + | buf.List(frame) | |||
| 47 | + | buf.Release() | |||
| 45 | b.ReportAllocs() | 48 | b.ReportAllocs() | ||
| 49 | + | b.ResetTimer() | |||
| 46 | for i := 0; i < b.N; i++ { | 50 | for i := 0; i < b.N; i++ { | ||
| 47 | instances, batches, stats := buf.List(frame) | 51 | instances, batches, stats := buf.List(frame) | ||
| 48 | if len(instances) != 2000 || len(batches) == 0 || len(stats.Skipped) != 0 { | 52 | if len(instances) != 2000 || len(batches) == 0 || len(stats.Skipped) != 0 { | ||
M internal/render/prepare_alloc_test.go +1 -1
| @@ -119,7 +119,7 @@ func TestPrepareQuadAllocationsDoNotScaleWithCommands(t *testing.T) { | |||
| 119 | 119 | t.Fatal(err) | |
| 120 | 120 | } | |
| 121 | 121 | }) | |
| 122 | - | if allocs > 3 { | |
| 122 | + | if allocs > 2 { | |
| 123 | 123 | t.Fatalf("%v allocs for 512 rects, want a small constant", allocs) | |
| 124 | 124 | } | |
| 125 | 125 | } | |
| @@ -119,7 +119,7 @@ func TestPrepareQuadAllocationsDoNotScaleWithCommands(t *testing.T) { | |||||
| 119 | t.Fatal(err) | 119 | t.Fatal(err) | ||
| 120 | } | 120 | } | ||
| 121 | }) | 121 | }) | ||
| 122 | - | if allocs > 3 { | 122 | + | if allocs > 2 { |
| 123 | t.Fatalf("%v allocs for 512 rects, want a small constant", allocs) | 123 | t.Fatalf("%v allocs for 512 rects, want a small constant", allocs) | ||
| 124 | } | 124 | } | ||
| 125 | } | 125 | } | ||