1//go:build stress23package ui45import (6 "fmt"7 "testing"89 "src.rest/cat/012/internal/sheet"10 "src.rest/cat/012/internal/stress"11)1213// BenchmarkTrace is an arrow key through to its frame on sheets of a14// million cells, with tracing off and on: a chain of a million formulas,15// a cell read by a million formulas (the pointer moving onto and off16// it), and a million numbers. Tracing costs the links it lists, capped,17// and a question per cell on screen.18func BenchmarkTrace(b *testing.B) {19 const million = 1 << 2020 shapes := []struct {21 name string22 build func() *sheet.Sheet23 }{24 {"chain-1M", func() *sheet.Sheet { return stress.Chain(million) }},25 {"fanout-1M", func() *sheet.Sheet { return stress.FanOut(million - 1) }},26 {"dense-1M", func() *sheet.Sheet { return stress.Dense(stress.Rows, million/stress.Rows) }},27 }28 for _, sh := range shapes {29 s := lazy(sh.build)30 for _, on := range []bool{false, true} {31 b.Run(fmt.Sprintf("arrow/%s/on=%v/200x60", sh.name, on), func(b *testing.B) {32 m := sized(s(), 200, 60)33 t := newFakeTerm(200, 60)34 m.tview = nil35 if on {36 m.runCommand("view.trace")37 }38 keys := []string{"down", "up"}39 i := 040 for b.Loop() {41 m.Update(key(keys[i%len(keys)]))42 t.frame(m)43 i++44 }45 })46 }47 }48}