From 416e55bedb4a083a7378c6e857903bd856fc50d9 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 10 Apr 2023 16:35:08 +0200 Subject: [PATCH] github.com/docker/cli/cli/command/system: add BenchmarkPrettyPrintInfo goos: linux goarch: arm64 pkg: github.com/docker/cli/cli/command/system BenchmarkPrettyPrintInfo BenchmarkPrettyPrintInfo-5 189028 6156 ns/op 1776 B/op 88 allocs/op Signed-off-by: Sebastiaan van Stijn --- cli/command/system/info_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cli/command/system/info_test.go b/cli/command/system/info_test.go index 298fa5d963..5fc55ccd1e 100644 --- a/cli/command/system/info_test.go +++ b/cli/command/system/info_test.go @@ -419,6 +419,30 @@ func TestPrettyPrintInfo(t *testing.T) { } } +func BenchmarkPrettyPrintInfo(b *testing.B) { + infoWithSwarm := sampleInfoNoSwarm + infoWithSwarm.Swarm = sampleSwarmInfo + + dockerInfo := info{ + Info: &infoWithSwarm, + ClientInfo: &clientInfo{ + clientVersion: clientVersion{ + Platform: &platformInfo{Name: "Docker Engine - Community"}, + Version: "24.0.0", + Context: "default", + }, + Debug: true, + }, + } + cli := test.NewFakeCli(&fakeClient{}) + + b.ReportAllocs() + for i := 0; i < b.N; i++ { + _ = prettyPrintInfo(cli, dockerInfo) + cli.ResetOutputBuffers() + } +} + func TestFormatInfo(t *testing.T) { for _, tc := range []struct { doc string