You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We allocate once via "make([]byte, len)",
and again when that buffer is converted to a string.
Thankfully, since Go 1.10 we have strings.Builder,
designed specifically for this use case.
In a downstream benchmark in go-car,
which needs to reconstruct many CID values,
we see small but nice gains:
name old time/op new time/op delta
ReadBlocks-16 1.09ms ± 4% 1.06ms ± 5% -3.33% (p=0.007 n=11+11)
name old speed new speed delta
ReadBlocks-16 478MB/s ± 4% 494MB/s ± 5% +3.46% (p=0.007 n=11+11)
name old alloc/op new alloc/op delta
ReadBlocks-16 1.30MB ± 0% 1.25MB ± 0% -3.86% (p=0.000 n=12+12)
name old allocs/op new allocs/op delta
ReadBlocks-16 9.50k ± 0% 8.45k ± 0% -11.05% (p=0.000 n=12+12)
0 commit comments