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		Known:        true,
30		SchemeKnown:  true,
31		UsePalette:   true,
32	}
33}
34
35func TestNewStylesAllocations(t *testing.T) {
36	theme := benchmarkPaletteTheme()
37	allocs := testing.AllocsPerRun(1000, func() {
38		benchmarkStylesSink = NewStyles(theme)
39	})
40	if allocs != 0 {
41		t.Fatalf("NewStyles allocations/op = %v, want 0", allocs)
42	}
43}
44
45func BenchmarkNewStyles(b *testing.B) {
46	theme := benchmarkPaletteTheme()
47	b.ReportAllocs()
48	for b.Loop() {
49		benchmarkStylesSink = NewStyles(theme)
50	}
51}
52
53func TestResolveAllocations(t *testing.T) {
54	theme := benchmarkPaletteTheme()
55	allocs := testing.AllocsPerRun(1000, func() {
56		benchmarkResolvedSink = Resolve(theme, domain.ThemeAccent{Mode: domain.ThemeAccentAuto})
57	})
58	if allocs != 0 {
59		t.Fatalf("Resolve allocations/op = %v, want 0", allocs)
60	}
61}
62
63func BenchmarkResolve(b *testing.B) {
64	theme := benchmarkPaletteTheme()
65	policy := domain.ThemeAccent{Mode: domain.ThemeAccentAuto}
66	b.ReportAllocs()
67	for b.Loop() {
68		benchmarkResolvedSink = Resolve(theme, policy)
69	}
70}

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