]> Cypherpunks repositories - gostls13.git/commitdiff
text/tabwriter: fix BenchmarkPyramid and BenchmarkRagged again
authorJosh Bleecher Snyder <josharian@gmail.com>
Sun, 3 Jun 2018 14:26:16 +0000 (07:26 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 4 Jun 2018 17:32:17 +0000 (17:32 +0000)
These were added in CL 106979. I got them wrong.
They were fixed in CL 111643. They were still wrong.
Hopefully this change will be the last fix.

With this fix, CL 106979 is allocation-neutral for BenchmarkRagged.
The performance results for BenchmarkPyramid reported in CL 111643 stand.

Change-Id: Id6a522e6602e5df31f504adf5a3bec9969c18649
Reviewed-on: https://go-review.googlesource.com/116015
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/text/tabwriter/tabwriter_test.go

index 2dddd5233c9ea306796ef7997291d04f7004fe70..07bae0ca0b2bf673d28a2510f3b122803e3dce0f 100644 (file)
@@ -693,7 +693,6 @@ func BenchmarkPyramid(b *testing.B) {
        for _, x := range [...]int{10, 100, 1000} {
                // Build a line with x cells.
                line := bytes.Repeat([]byte("a\t"), x)
-               line = append(line, '\n')
                b.Run(fmt.Sprintf("%d", x), func(b *testing.B) {
                        b.ReportAllocs()
                        for i := 0; i < b.N; i++ {
@@ -712,9 +711,8 @@ func BenchmarkPyramid(b *testing.B) {
 func BenchmarkRagged(b *testing.B) {
        var lines [8][]byte
        for i, w := range [8]int{6, 2, 9, 5, 5, 7, 3, 8} {
-               // Build a line with x cells.
+               // Build a line with w cells.
                lines[i] = bytes.Repeat([]byte("a\t"), w)
-               lines[i] = append(lines[i], '\n')
        }
        for _, h := range [...]int{10, 100, 1000} {
                b.Run(fmt.Sprintf("%d", h), func(b *testing.B) {