MCPcopy Create free account
hub / github.com/docker/cli / BenchmarkPyramid

Function BenchmarkPyramid

cli/command/formatter/tabwriter/tabwriter_test.go:695–712  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

693}
694
695func BenchmarkPyramid(b *testing.B) {
696 for _, x := range [...]int{10, 100, 1000} {
697 // Build a line with x cells.
698 line := bytes.Repeat([]byte("a\t"), x)
699 b.Run(strconv.Itoa(x), func(b *testing.B) {
700 b.ReportAllocs()
701 for i := 0; i < b.N; i++ {
702 w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
703 // Write increasing prefixes of that line.
704 for j := range x {
705 w.Write(line[:j*2])
706 w.Write([]byte{'\n'})
707 }
708 w.Flush()
709 }
710 })
711 }
712}
713
714func BenchmarkRagged(b *testing.B) {
715 var lines [8][]byte

Callers

nothing calls this directly

Calls 3

WriteMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…