Skip to content

Commit

Permalink
fix(tabwriter): update for loop (#4406)
Browse files Browse the repository at this point in the history
  • Loading branch information
Laure-di authored Jan 8, 2025
1 parent d03f829 commit a8421ad
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/tabwriter/tabwriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ func BenchmarkTable(b *testing.B) {
b.Run(fmt.Sprintf("%dx%d", w, h), func(b *testing.B) {
b.Run("new", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
w := tabwriter.NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
// Write the line h times.
for range h {
Expand All @@ -713,7 +713,7 @@ func BenchmarkTable(b *testing.B) {
b.Run("reuse", func(b *testing.B) {
b.ReportAllocs()
w := tabwriter.NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
for i := 0; i < b.N; i++ {
for range b.N {
// Write the line h times.
for range h {
w.Write(line)
Expand All @@ -732,7 +732,7 @@ func BenchmarkPyramid(b *testing.B) {
line := bytes.Repeat([]byte("a\t"), x)
b.Run(strconv.Itoa(x), func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
w := tabwriter.NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
// Write increasing prefixes of that line.
for j := range x {
Expand All @@ -754,7 +754,7 @@ func BenchmarkRagged(b *testing.B) {
for _, h := range [...]int{10, 100, 1000} {
b.Run(strconv.Itoa(h), func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
w := tabwriter.NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
// Write the lines in turn h times.
for j := range h {
Expand Down Expand Up @@ -782,7 +782,7 @@ lines

func BenchmarkCode(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
w := tabwriter.NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
// The code is small, so it's reasonable for the tabwriter user
// to write it all at once, or buffer the writes.
Expand Down

0 comments on commit a8421ad

Please sign in to comment.