v0.6.1 aa12db3

benchmark_test.go RawHistoryFolder

1package render
2
3import (
4	"testing"
5
6	"github.com/bnema/nefergui/internal/css"
7	"github.com/bnema/nefergui/internal/layout"
8	"github.com/bnema/nefergui/internal/text"
9)
10
11// BenchmarkPrepare exercises the product example's text and box display-list mix.
12func BenchmarkPrepare(b *testing.B) {
13	catalog, err := text.Load(text.DirectorySource("../../testdata/fonts"))
14	if err != nil {
15		b.Fatal(err)
16	}
17	engine := text.NewEngine(catalog)
18	var commands []layout.Command
19	labels := []string{"Demo", "Accueil", "Paramètres", "Thème sombre", "Bienvenue", "Une interface native écrite entièrement en Go.", "Votre nom", "Continuer", "Bonjour Ada"}
20	for i, label := range labels {
21		measured, err := engine.Measure(label, text.Request{Families: []string{"Noto Sans"}, Size: 16}, 0)
22		if err != nil {
23			b.Fatal(err)
24		}
25		commands = append(commands, layout.Command{Op: "rect", Rect: layout.Rect{X: 10, Y: float64(i * 45), W: 320, H: 35}, Color: css.Color{A: 1}, Opacity: 1})
26		cmd := layout.Command{Op: "text", Rect: layout.Rect{X: 20, Y: float64(i * 45), W: 300, H: 35}, Color: css.Color{A: 1}, Opacity: 1}
27		for _, line := range measured.Lines {
28			for _, run := range line.Runs {
29				r := layout.Run{Face: run.Face, FaceID: run.Face.ID, Size: 16}
30				for _, glyph := range run.Glyphs {
31					r.Glyphs = append(r.Glyphs, layout.Glyph{ID: uint32(glyph.ID), X: 20 + glyph.X, Y: float64(i*45+20) + glyph.Y})
32				}
33				cmd.Runs = append(cmd.Runs, r)
34			}
35		}
36		commands = append(commands, cmd)
37	}
38	p, err := NewPreparer(1024, 4)
39	if err != nil {
40		b.Fatal(err)
41	}
42	warm, err := p.Prepare(commands, 1, 960, 640)
43	if err != nil {
44		b.Fatal(err)
45	}
46	p.Submitted(warm.Uploads)
47	b.ReportAllocs()
48	b.ResetTimer()
49	for i := 0; i < b.N; i++ {
50		frame, err := p.Prepare(commands, 1, 960, 640)
51		if err != nil || len(frame.Quads) == 0 {
52			b.Fatalf("prepare: %v", err)
53		}
54		p.Submitted(frame.Uploads)
55	}
56}

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 1

Tags 12

↑↓ moveenter openesc close