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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-04-10 16:35:08 +02:00
parent afd320c5ab
commit 416e55bedb
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 24 additions and 0 deletions

View File

@ -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) { func TestFormatInfo(t *testing.T) {
for _, tc := range []struct { for _, tc := range []struct {
doc string doc string