From 378383dd6993efb28f0bcf5056875e9ca6f32fae Mon Sep 17 00:00:00 2001 From: Ilker Manap Date: Wed, 16 Sep 2026 09:59:55 +0200 Subject: [PATCH] Align the bench table, which a tabwriter cannot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rows are printed as each concurrency level finishes, and a tabwriter lays out only what has been flushed — so it aligned the header and the first row to each other and every row after that to nothing. Fixed columns instead. Co-Authored-By: Claude Opus 5 (1M context) --- internal/cli/bench.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/internal/cli/bench.go b/internal/cli/bench.go index 1b37d75..3d4d2a0 100644 --- a/internal/cli/bench.go +++ b/internal/cli/bench.go @@ -3,7 +3,6 @@ package cli import ( "encoding/json" "fmt" - "text/tabwriter" "time" "github.com/spf13/cobra" @@ -49,8 +48,14 @@ func newBenchCmd(asJSON *bool) *cobra.Command { } cmd.PrintErrf("benchmarking %s against %s\n\n", cfg.Model, cfg.Target) - w := tabwriter.NewWriter(cmd.ErrOrStderr(), 0, 0, 2, ' ', 0) - fmt.Fprintln(w, "CONC\tREQ/S\tTOK/S\tTTFT p50\tTTFT p99\tTPOT p99\tWAIT\tKV\tSLO") + // Fixed columns rather than a tabwriter: rows are printed as each + // level finishes, and a tabwriter cannot align a column it has not + // seen the rest of yet — it lays out whatever has been flushed, so + // every row after the first came out ragged. + const row = "%-5s %-7s %-7s %-9s %-9s %-9s %-6s %-5s %s\n" + fmt.Fprintf(cmd.ErrOrStderr(), row, + "CONC", "REQ/S", "TOK/S", "TTFT p50", "TTFT p99", "TPOT p99", "WAIT", "KV", "SLO") + progress := func(s bench.Step) { verdict := "ok" if !s.MeetsSLO { @@ -59,11 +64,14 @@ func newBenchCmd(asJSON *bool) *cobra.Command { if s.Failed > 0 { verdict = fmt.Sprintf("%d failed", s.Failed) } - fmt.Fprintf(w, "%d\t%.1f\t%.0f\t%s\t%s\t%s\t%.1f\t%.0f%%\t%s\n", - s.Concurrency, s.RequestsPerSec, s.TokensPerSec, + fmt.Fprintf(cmd.ErrOrStderr(), row, + fmt.Sprint(s.Concurrency), + fmt.Sprintf("%.1f", s.RequestsPerSec), + fmt.Sprintf("%.0f", s.TokensPerSec), ms(s.TTFT.P50), ms(s.TTFT.P99), ms(s.TPOT.P99), - s.Waiting, s.KVUsage*100, verdict) - _ = w.Flush() + fmt.Sprintf("%.1f", s.Waiting), + fmt.Sprintf("%.0f%%", s.KVUsage*100), + verdict) } res, err := bench.Run(cmd.Context(), cfg, progress)