v0.6.0 b250c5e

storage_tuning_test.go RawHistoryFolder

1package vt
2
3import (
4	"fmt"
5	"runtime"
6	"testing"
7
8	"github.com/bnema/vev-vt/core"
9)
10
11func TestHistoryTailPreallocationFollowsGeometry(t *testing.T) {
12	h := NewHistory(HistoryConfig{MaxRows: 4, MaxBytes: 1 << 20, ChunkRows: 4})
13	if err := h.Append(historyRow("abc"), LineBound{End: 3}); err != nil {
14		t.Fatal(err)
15	}
16	if got := cap(h.tailCells); got > 12 {
17		t.Fatalf("tail preallocation = %d cells, want at most 4x3", got)
18	}
19}
20
21func BenchmarkHistoryChunkSize(b *testing.B) {
22	for _, rows := range []int{32, 64, 128, 256} {
23		b.Run(fmt.Sprintf("rows-%d", rows), func(b *testing.B) {
24			b.ReportAllocs()
25			for b.Loop() {
26				h := NewHistory(HistoryConfig{MaxRows: 10_000, MaxBytes: 1 << 30, ChunkRows: rows})
27				row := make([]core.Cell, 120)
28				for x := range row {
29					row[x] = core.Cell{Rune: rune('a' + x%26), Style: core.DefaultStyle()}
30				}
31				for range 10_000 {
32					if err := h.Append(row, LineBound{End: 120}); err != nil {
33						b.Fatal(err)
34					}
35				}
36				benchmarkStorageHistorySink = h
37			}
38		})
39	}
40}
41
42func BenchmarkSmallHistoryRetained(b *testing.B) {
43	var retained uint64
44	for b.Loop() {
45		benchmarkStorageHistorySink = nil
46		runtime.GC()
47		var before, after runtime.MemStats
48		runtime.ReadMemStats(&before)
49		h := NewHistory(HistoryConfig{MaxRows: 4, MaxBytes: 1 << 20, ChunkRows: 4})
50		if err := h.Append(historyRow("abc"), LineBound{End: 3}); err != nil {
51			b.Fatal(err)
52		}
53		benchmarkStorageHistorySink = h
54		runtime.GC()
55		runtime.ReadMemStats(&after)
56		if after.HeapAlloc >= before.HeapAlloc {
57			retained += after.HeapAlloc - before.HeapAlloc
58		}
59	}
60	b.ReportMetric(float64(retained)/float64(b.N), "retained-B/op")
61}

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