v0.6.1 aa12db3

instances_bench_test.go RawHistoryFolder

1package render
2
3import (
4	"image"
5	"testing"
6
7	"github.com/bnema/nefergui/internal/css"
8	"github.com/bnema/nefergui/internal/layout"
9	"github.com/bnema/nefergui/internal/text"
10)
11
12// listFixture is a product-like mix: atlas draws with an image every 50 quads.
13func listFixture(n int) Frame {
14	img := image.NewRGBA(image.Rect(0, 0, 2, 2))
15	quads := make([]Quad, n)
16	for i := range quads {
17		switch {
18		case i%50 == 49:
19			quads[i] = Quad{Op: "image", Image: img, Rect: layout.Rect{W: 4, H: 4}}
20		case i%3 == 0:
21			quads[i] = Quad{Op: "glyph", Glyph: text.Placement{Page: 1, Rect: image.Rect(1, 2, 9, 12)}, Color: css.Color{A: 1}}
22		case i%7 == 0:
23			quads[i] = Quad{Op: "border", Color: css.Color{A: 1}}
24		default:
25			quads[i] = Quad{Op: "rect", Rect: layout.Rect{X: float64(i), W: 3, H: 3}, Color: css.Color{A: 1}}
26		}
27	}
28	return Frame{Quads: quads}
29}
30
31func BenchmarkListBatches(b *testing.B) {
32	frame := listFixture(2000)
33	b.ReportAllocs()
34	b.ResetTimer()
35	for i := 0; i < b.N; i++ {
36		instances, batches, stats := ListBatches(frame)
37		if len(instances) != 2000 || len(batches) == 0 || len(stats.Skipped) != 0 {
38			b.Fatal("list")
39		}
40	}
41}
42
43func BenchmarkListBufferReuse(b *testing.B) {
44	frame := listFixture(2000)
45	var buf ListBuffer
46	buf.List(frame)
47	buf.Release()
48	b.ReportAllocs()
49	b.ResetTimer()
50	for i := 0; i < b.N; i++ {
51		instances, batches, stats := buf.List(frame)
52		if len(instances) != 2000 || len(batches) == 0 || len(stats.Skipped) != 0 {
53			b.Fatal("list")
54		}
55	}
56}

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 1

Tags 12

↑↓ moveenter openesc close