benchmark_test.go RawHistoryFolder

1package theme
2
3import (
4	"testing"
5
6	renderer "github.com/bnema/vev-vt"
7	"github.com/bnema/vev/internal/domain"
8)
9
10var (
11	benchmarkStylesSink   Styles
12	benchmarkResolvedSink ResolvedTheme
13)
14
15func benchmarkPaletteTheme() Theme {
16	return Theme{
17		Foreground: renderer.RGB{R: 0xd8, G: 0xdc, B: 0xe8},
18		Background: renderer.RGB{R: 0x08, G: 0x09, B: 0x0a},
19		Palette: [16]renderer.RGB{
20			2:  {R: 0x7d, G: 0xb5, B: 0xb5},
21			4:  {R: 0x6c, G: 0x9b, B: 0xd9},
22			10: {R: 0x7d, G: 0xb5, B: 0xb5},
23			12: {R: 0x6c, G: 0x9b, B: 0xd9},
24			14: {R: 0x7d, G: 0xb5, B: 0xb5},
25		},
26		PaletteKnown: 1<<2 | 1<<4 | 1<<10 | 1<<12 | 1<<14,
27		HasFG:        true,
28		HasBG:        true,
29		TrueColor:    true,
30		Known:        true,
31		SchemeKnown:  true,
32		UsePalette:   true,
33	}
34}
35
36func TestNewStylesAllocations(t *testing.T) {
37	theme := benchmarkPaletteTheme()
38	allocs := testing.AllocsPerRun(1000, func() {
39		benchmarkStylesSink = NewStyles(theme)
40	})
41	if allocs != 0 {
42		t.Fatalf("NewStyles allocations/op = %v, want 0", allocs)
43	}
44}
45
46func BenchmarkNewStyles(b *testing.B) {
47	theme := benchmarkPaletteTheme()
48	b.ReportAllocs()
49	for b.Loop() {
50		benchmarkStylesSink = NewStyles(theme)
51	}
52}
53
54func TestResolveAllocations(t *testing.T) {
55	theme := benchmarkPaletteTheme()
56	allocs := testing.AllocsPerRun(1000, func() {
57		benchmarkResolvedSink = Resolve(theme, domain.ThemeAccent{Mode: domain.ThemeAccentAuto})
58	})
59	if allocs != 0 {
60		t.Fatalf("Resolve allocations/op = %v, want 0", allocs)
61	}
62}
63
64func BenchmarkResolve(b *testing.B) {
65	theme := benchmarkPaletteTheme()
66	policy := domain.ThemeAccent{Mode: domain.ThemeAccentAuto}
67	b.ReportAllocs()
68	for b.Loop() {
69		benchmarkResolvedSink = Resolve(theme, policy)
70	}
71}

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 12

Tags 11

↑↓ moveenter openesc close