sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Reduce allocations in fixBound

Open pencil opened this issue 3 years ago • 2 comments

Reduces allocations by initializing bytes.Buffer with correct target capacity.

benchmark                  old ns/op     new ns/op     delta
BenchmarkFixBound10-8      346           324           -6.42%
BenchmarkFixBound100-8     1410          1170          -17.02%

benchmark                  old allocs     new allocs     delta
BenchmarkFixBound10-8      4              3              -25.00%
BenchmarkFixBound100-8     7              3              -57.14%

benchmark                  old bytes     new bytes     delta
BenchmarkFixBound10-8      354           273           -22.88%
BenchmarkFixBound100-8     3294          2082          -36.79%

pencil avatar Jan 28 '22 17:01 pencil

@jmoiron WDYT about merging this?

pedia avatar May 05 '22 15:05 pedia

@jmoiron WDYT about merging this?

pedia avatar May 05 '22 15:05 pedia