| 693 | } |
| 694 | |
| 695 | func 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 | |
| 714 | func BenchmarkRagged(b *testing.B) { |
| 715 | var lines [8][]byte |