detached 2a2a3fb

test(daemon): remove timed fixture allocations

commit
2a2a3fb601fc8c36c839c31de1949cb43baf98d4
author
brice · · 2026-07-11 05:00 UTC
committer
brice · · 2026-07-11 06:15 UTC
parent
0ba01b1
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +30 -9
M internal/usecase/daemon/performance_benchmark_test.go +30 -9
@@ -36,6 +36,21 @@ func TestPerformanceFixtureCounters(t *testing.T) {
3636 require.True(t, fixture.resized())
3737 }
3838
39+func TestPerformanceFixturePaintLiveUsesPrecomputedAlternatingWrites(t *testing.T) {
40+ fixture := newPerformanceFixture(t, performanceConfig{})
41+
42+ require.NotNil(t, fixture.activePane)
43+ require.Equal(t, [][]byte{
44+ []byte("\x1b[1;1HA\x1b[2;2HA"),
45+ []byte("\x1b[1;1HB\x1b[2;2HB"),
46+ }, fixture.liveWrites)
47+
48+ for range 4 {
49+ fixture.paintLive()
50+ }
51+ require.Equal(t, uint64(4), fixture.metrics().outputFrames)
52+}
53+
3954 // performanceConfig intentionally describes only an in-process daemon shape:
4055 // no PTY readers, schedulers, clocks, or transports are started by this fixture.
4156 type performanceConfig struct {
@@ -57,6 +72,8 @@ type performanceFixture struct {
5772 ac *attachedClient
5873 output *countingOutputTransport
5974 snaps *countingSnapshotStore
75+ activePane *pane
76+ liveWrites [][]byte
6077 paints int
6178 resizedSize domain.Size
6279 }
@@ -74,11 +91,20 @@ func newPerformanceFixture(t testing.TB, config performanceConfig) *performanceF
7491 sess.ephemeral = false
7592 sess.snapEligible.Store(true)
7693
77- fixture := &performanceFixture{t: t, d: d, sess: sess, ac: ac, output: output, snaps: &countingSnapshotStore{}}
94+ fixture := &performanceFixture{
95+ t: t,
96+ d: d,
97+ sess: sess,
98+ ac: ac,
99+ output: output,
100+ snaps: &countingSnapshotStore{},
101+ liveWrites: [][]byte{[]byte("\x1b[1;1HA\x1b[2;2HA"), []byte("\x1b[1;1HB\x1b[2;2HB")},
102+ }
78103 WithSnapshotStore(fixture.snaps)(d)
79104 for tabIndex, tb := range sess.tabs {
80105 fixture.configureTab(tb, tabIndex, tabSize(config.size))
81106 }
107+ fixture.activePane = fixture.findActivePane()
82108
83109 // Prime the real renderer shadow before measurements. Subsequent paints use
84110 // actual production diffs rather than the initial full frame.
@@ -123,7 +149,7 @@ func performanceFullWidthRow(width, tabIndex, row int) string {
123149 return string(out)
124150 }
125151
126-func (f *performanceFixture) activePane() *pane {
152+func (f *performanceFixture) findActivePane() *pane {
127153 f.t.Helper()
128154 tb := f.sess.activeTab()
129155 require.NotNil(f.t, tb)
@@ -133,14 +159,9 @@ func (f *performanceFixture) activePane() *pane {
133159 }
134160
135161 func (f *performanceFixture) paintLive() {
136- f.t.Helper()
137- p := f.activePane()
138- x, y := 1, 1
139- if f.paints%2 == 1 {
140- x, y = 2, 2
141- }
162+ p := f.activePane
142163 p.mu.Lock()
143- p.screen.Write([]byte(fmt.Sprintf("\x1b[%d;%dH%c", y, x, 'A'+rune(f.paints))))
164+ p.screen.Write(f.liveWrites[f.paints%len(f.liveWrites)])
144165 p.mu.Unlock()
145166 f.d.paint(f.sess, f.ac, false)
146167 f.paints++
@@ -36,6 +36,21 @@ func TestPerformanceFixtureCounters(t *testing.T) {
36 require.True(t, fixture.resized())36 require.True(t, fixture.resized())
37 }37 }
38 38
39+func TestPerformanceFixturePaintLiveUsesPrecomputedAlternatingWrites(t *testing.T) {
40+ fixture := newPerformanceFixture(t, performanceConfig{})
41+
42+ require.NotNil(t, fixture.activePane)
43+ require.Equal(t, [][]byte{
44+ []byte("\x1b[1;1HA\x1b[2;2HA"),
45+ []byte("\x1b[1;1HB\x1b[2;2HB"),
46+ }, fixture.liveWrites)
47+
48+ for range 4 {
49+ fixture.paintLive()
50+ }
51+ require.Equal(t, uint64(4), fixture.metrics().outputFrames)
52+}
53+
39 // performanceConfig intentionally describes only an in-process daemon shape:54 // performanceConfig intentionally describes only an in-process daemon shape:
40 // no PTY readers, schedulers, clocks, or transports are started by this fixture.55 // no PTY readers, schedulers, clocks, or transports are started by this fixture.
41 type performanceConfig struct {56 type performanceConfig struct {
@@ -57,6 +72,8 @@ type performanceFixture struct {
57 ac *attachedClient72 ac *attachedClient
58 output *countingOutputTransport73 output *countingOutputTransport
59 snaps *countingSnapshotStore74 snaps *countingSnapshotStore
75+ activePane *pane
76+ liveWrites [][]byte
60 paints int77 paints int
61 resizedSize domain.Size78 resizedSize domain.Size
62 }79 }
@@ -74,11 +91,20 @@ func newPerformanceFixture(t testing.TB, config performanceConfig) *performanceF
74 sess.ephemeral = false91 sess.ephemeral = false
75 sess.snapEligible.Store(true)92 sess.snapEligible.Store(true)
76 93
77- fixture := &performanceFixture{t: t, d: d, sess: sess, ac: ac, output: output, snaps: &countingSnapshotStore{}}94+ fixture := &performanceFixture{
95+ t: t,
96+ d: d,
97+ sess: sess,
98+ ac: ac,
99+ output: output,
100+ snaps: &countingSnapshotStore{},
101+ liveWrites: [][]byte{[]byte("\x1b[1;1HA\x1b[2;2HA"), []byte("\x1b[1;1HB\x1b[2;2HB")},
102+ }
78 WithSnapshotStore(fixture.snaps)(d)103 WithSnapshotStore(fixture.snaps)(d)
79 for tabIndex, tb := range sess.tabs {104 for tabIndex, tb := range sess.tabs {
80 fixture.configureTab(tb, tabIndex, tabSize(config.size))105 fixture.configureTab(tb, tabIndex, tabSize(config.size))
81 }106 }
107+ fixture.activePane = fixture.findActivePane()
82 108
83 // Prime the real renderer shadow before measurements. Subsequent paints use109 // Prime the real renderer shadow before measurements. Subsequent paints use
84 // actual production diffs rather than the initial full frame.110 // actual production diffs rather than the initial full frame.
@@ -123,7 +149,7 @@ func performanceFullWidthRow(width, tabIndex, row int) string {
123 return string(out)149 return string(out)
124 }150 }
125 151
126-func (f *performanceFixture) activePane() *pane {152+func (f *performanceFixture) findActivePane() *pane {
127 f.t.Helper()153 f.t.Helper()
128 tb := f.sess.activeTab()154 tb := f.sess.activeTab()
129 require.NotNil(f.t, tb)155 require.NotNil(f.t, tb)
@@ -133,14 +159,9 @@ func (f *performanceFixture) activePane() *pane {
133 }159 }
134 160
135 func (f *performanceFixture) paintLive() {161 func (f *performanceFixture) paintLive() {
136- f.t.Helper()162+ p := f.activePane
137- p := f.activePane()
138- x, y := 1, 1
139- if f.paints%2 == 1 {
140- x, y = 2, 2
141- }
142 p.mu.Lock()163 p.mu.Lock()
143- p.screen.Write([]byte(fmt.Sprintf("\x1b[%d;%dH%c", y, x, 'A'+rune(f.paints))))164+ p.screen.Write(f.liveWrites[f.paints%len(f.liveWrites)])
144 p.mu.Unlock()165 p.mu.Unlock()
145 f.d.paint(f.sess, f.ac, false)166 f.d.paint(f.sess, f.ac, false)
146 f.paints++167 f.paints++

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 13

↑↓ moveenter openesc close