Closed cristaloleg closed 3 months ago
Reduce a bit of allocations and cpu time in Hash arshaling methods. Same behaviour as before but slightly in another way: instead of operations on string we can do this on []byte. As a result we now have tests for that.
Hash
string
[]byte
go-header % go-perftuner bstat a.txt b.txt args: [a.txt b.txt]name old time/op new time/op delta HashMarshaling/String-10 798ns ± 0% 613ns ± 0% -23.08% (p=0.002 n=6+6) HashMarshaling/Marshal-10 1.11µs ± 0% 0.84µs ± 0% -24.55% (p=0.004 n=5+6) HashMarshaling/Unmarshal-10 333ns ±11% 277ns ± 1% -16.92% (p=0.004 n=5+6) name old alloc/op new alloc/op delta HashMarshaling/String-10 192B ± 0% 128B ± 0% -33.33% (p=0.002 n=6+6) HashMarshaling/Marshal-10 296B ± 0% 104B ± 0% -64.86% (p=0.002 n=6+6) HashMarshaling/Unmarshal-10 128B ± 0% 32B ± 0% -75.00% (p=0.002 n=6+6) name old allocs/op new allocs/op delta HashMarshaling/String-10 3.00 ± 0% 2.00 ± 0% ~ (p=0.002 n=6+6) HashMarshaling/Marshal-10 5.00 ± 0% 2.00 ± 0% -60.00% (p=0.002 n=6+6) HashMarshaling/Unmarshal-10 2.00 ± 0% 1.00 ± 0% ~ (p=0.002 n=6+6)
@renaynay added a fuzzing test for hexToUpper (to run: go test -v -run=^$ -fuzz=Fuzz_hexToUpper .)
hexToUpper
go test -v -run=^$ -fuzz=Fuzz_hexToUpper .
Overview
Reduce a bit of allocations and cpu time in
Hash
arshaling methods. Same behaviour as before but slightly in another way: instead of operations onstring
we can do this on[]byte
. As a result we now have tests for that.