common/hexutil: improve performance of EncodeBig (#23780)
- use Text instead of fmt.Sprintf - reduced allocs from 6 to 2 - improved speed
This commit is contained in:
@ -201,3 +201,15 @@ func TestDecodeUint64(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkEncodeBig(b *testing.B) {
|
||||
for _, bench := range encodeBigTests {
|
||||
b.Run(bench.want, func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
bigint := bench.input.(*big.Int)
|
||||
for i := 0; i < b.N; i++ {
|
||||
EncodeBig(bigint)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user