I built Peacock, a terminal JSON log viewer in Go, and it could not keep up with a busy log stream. So I profiled it with go tool pprof: read the profile, fix the hottest line, re-profile, repeat. On a real 70x240 terminal, throughput went from 52 lines/sec to 651 lines/sec, about 12x.

The most useful lesson, though, came from an evening I lost to a bug in my own benchmark.

Cleanup: a pointless join/split

The base profile flagged a viewport setter eating 8% of CPU. SetContent takes a string and splits it on \n:

0 29.66s 227: m.SetContentLines(strings.Split(s, "\n"))