MCPcopy Index your code
hub / github.com/docker/cli / BenchmarkTable

Function BenchmarkTable

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

Source from the content-addressed store, hash-verified

658}
659
660func BenchmarkTable(b *testing.B) {
661 for _, w := range [...]int{1, 10, 100} {
662 // Build a line with w cells.
663 line := bytes.Repeat([]byte("a\t"), w)
664 line = append(line, '\n')
665 for _, h := range [...]int{10, 1000, 100000} {
666 b.Run(fmt.Sprintf("%dx%d", w, h), func(b *testing.B) {
667 b.Run("new", func(b *testing.B) {
668 b.ReportAllocs()
669 for i := 0; i < b.N; i++ {
670 w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
671 // Write the line h times.
672 for range h {
673 w.Write(line)
674 }
675 w.Flush()
676 }
677 })
678
679 b.Run("reuse", func(b *testing.B) {
680 b.ReportAllocs()
681 w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
682 for i := 0; i < b.N; i++ {
683 // Write the line h times.
684 for range h {
685 w.Write(line)
686 }
687 w.Flush()
688 }
689 })
690 })
691 }
692 }
693}
694
695func BenchmarkPyramid(b *testing.B) {
696 for _, x := range [...]int{10, 100, 1000} {

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…