From 153cdb2b0bd87bc1a1e753cfae3cee5c03ceccd5 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 22 Aug 2025 10:58:01 +0100 Subject: [PATCH] [PERF] PromQL: Replace Fprintf %f with AppendFloat The combination of `AvailableBuffer`` followed by `Write` is optimised inside `bytes.Buffer`. Signed-off-by: Bryan Boreham --- promql/parser/printer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promql/parser/printer.go b/promql/parser/printer.go index 00204abaef..34448ab8c0 100644 --- a/promql/parser/printer.go +++ b/promql/parser/printer.go @@ -373,7 +373,7 @@ func (node *VectorSelector) String() string { switch { case node.Timestamp != nil: b.WriteString(" @ ") - fmt.Fprintf(b, "%.3f", float64(*node.Timestamp)/1000.0) + b.Write(strconv.AppendFloat(b.AvailableBuffer(), float64(*node.Timestamp)/1000.0, 'f', 3, 64)) case node.StartOrEnd == START: b.WriteString(" @ start()") case node.StartOrEnd == END: