main ab6686c

benchmark_test.go RawHistoryFolder

1package html
2
3import (
4	"fmt"
5	"testing"
6
7	"github.com/bnema/vev-vt/core"
8)
9
10func BenchmarkRenderer(b *testing.B) {
11	for _, size := range []struct{ width, height int }{{80, 24}, {120, 40}, {240, 80}} {
12		frame := core.NewFrame(size.width, size.height)
13		for y := range size.height {
14			for x := range size.width {
15				frame.Set(x, y, core.Cell{Rune: rune('A' + (x+y)%26), Style: core.DefaultStyle()})
16			}
17		}
18		b.Run(fmt.Sprintf("snapshot-%dx%d", size.width, size.height), func(b *testing.B) {
19			b.ReportAllocs()
20			for range b.N {
21				renderer, err := New(Options{})
22				if err != nil {
23					b.Fatal(err)
24				}
25				prepared, err := renderer.Prepare(frame, nil, true, Cursor{})
26				if err != nil {
27					b.Fatal(err)
28				}
29				if err := prepared.Commit(); err != nil {
30					b.Fatal(err)
31				}
32			}
33		})
34		b.Run(fmt.Sprintf("one-row-%dx%d", size.width, size.height), func(b *testing.B) {
35			renderer, err := New(Options{})
36			if err != nil {
37				b.Fatal(err)
38			}
39			first, err := renderer.Prepare(frame, nil, false, Cursor{})
40			if err != nil {
41				b.Fatal(err)
42			}
43			if err := first.Commit(); err != nil {
44				b.Fatal(err)
45			}
46			left := frame.Clone()
47			right := frame.Clone()
48			right.Set(0, size.height/2, core.Cell{Rune: 'Z', Style: core.DefaultStyle()})
49			b.ReportAllocs()
50			b.ResetTimer()
51			for index := range b.N {
52				candidate := left
53				if index%2 == 0 {
54					candidate = right
55				}
56				prepared, err := renderer.Prepare(candidate, nil, false, Cursor{})
57				if err != nil {
58					b.Fatal(err)
59				}
60				if err := prepared.Commit(); err != nil {
61					b.Fatal(err)
62				}
63			}
64		})
65	}
66}

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