v0.7.0 4c16dd8

output_benchmark_test.go RawHistoryFolder

1package sessionwire
2
3import (
4	"bytes"
5	"math/rand"
6	"reflect"
7	"testing"
8
9	"github.com/bnema/vev/internal/domain"
10	"github.com/bnema/vev/internal/protocol"
11)
12
13// BenchmarkOutputProductionRoundTrip measures the complete production-owned
14// Output path: semantic validation/conversion, optional compression, Protobuf
15// marshal, strict scan/unmarshal, decompression, and semantic conversion.
16func BenchmarkOutputProductionRoundTrip(b *testing.B) {
17	fixtures := []struct {
18		name string
19		base uint64
20		new  uint64
21		full bool
22		data []byte
23	}{
24		{name: "incremental", base: 1, new: 2, data: []byte("prompt output\r\n")},
25		{name: "compressible_snapshot", new: 1, full: true, data: repeatedOutput(8 << 10)},
26		{name: "incompressible_snapshot", new: 1, full: true, data: randomOutput(8 << 10)},
27	}
28	for _, fixture := range fixtures {
29		b.Run(fixture.name, func(b *testing.B) {
30			message := protocol.Output{
31				Epoch:   1,
32				Base:    fixture.base,
33				New:     fixture.new,
34				Full:    fixture.full,
35				Size:    domain.Size{Cols: 120, Rows: 40},
36				Context: testUIOutputContext(),
37				Data:    fixture.data,
38			}
39			b.ReportAllocs()
40			b.SetBytes(int64(len(fixture.data)))
41			for b.Loop() {
42				encoded, err := EncodeServerMessage(message)
43				if err != nil {
44					b.Fatal(err)
45				}
46				decoded, err := DecodeServerEnvelope(encoded)
47				if err != nil {
48					b.Fatal(err)
49				}
50				output, ok := decoded.(protocol.Output)
51				if !ok {
52					b.Fatalf("decoded Output = %T", decoded)
53				}
54				if !reflect.DeepEqual(output, message) || !bytes.Equal(output.Data, fixture.data) {
55					b.Fatalf("decoded Output differs from input")
56				}
57			}
58		})
59	}
60}
61
62func repeatedOutput(size int) []byte {
63	pattern := []byte("\x1b[38;2;120;180;240mstyled viewport row\x1b[0m\r\n")
64	data := make([]byte, size)
65	for offset := 0; offset < len(data); offset += copy(data[offset:], pattern) {
66	}
67	return data
68}
69
70func randomOutput(size int) []byte {
71	data := make([]byte, size)
72	_, _ = rand.New(rand.NewSource(1)).Read(data)
73	return data
74}

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