Files
Leandro López (inkel) b821346005 Concatenate string instead of using fmt.Sprintf
The call to `fmt.Sprintf` does virtually the same as concatenating the
strings, but incurs in minor overhead from having to call a function,
and performs an additional allocation.

I've made a small benchmark for this and when run against current
`master` and this branch, the results are significant for this
function:

    goos: darwin
    goarch: arm64
    pkg: k8s.io/client-go/transport
    cpu: Apple M1 Pro
                              │ bart.base.log │           bart.concat.log            │
                              │    sec/op     │    sec/op     vs base                │
    BearerAuthRoundTripper-10    361.3n ± 31%   295.5n ± 11%  -18.21% (p=0.000 n=20)

                              │ bart.base.log │          bart.concat.log          │
                              │     B/op      │    B/op     vs base               │
    BearerAuthRoundTripper-10      768.0 ± 0%   752.0 ± 0%  -2.08% (p=0.000 n=20)

                              │ bart.base.log │          bart.concat.log           │
                              │   allocs/op   │ allocs/op   vs base                │
    BearerAuthRoundTripper-10      6.000 ± 0%   5.000 ± 0%  -16.67% (p=0.000 n=20)

Considering this method is likely used in many installations, the
gains, while small, adds up to bigger savings

Kubernetes-commit: 92a0e422df2d0d36c25f0b5c829c571b93250600
2025-06-06 08:27:49 -03:00
..