keys: add (*PublicKey).DecodeBytes benchmark
Attempts to reuse elliptic.Unmarshal() and elliptic.UnmarshalCompressed() lead to this: name old time/op new time/op delta PublicDecodeBytes-8 59.5µs ± 2% 61.8µs ± 1% +3.78% (p=0.000 n=10+9) name old alloc/op new alloc/op delta PublicDecodeBytes-8 3.99kB ± 0% 4.27kB ± 0% +6.81% (p=0.000 n=9+10) name old allocs/op new allocs/op delta PublicDecodeBytes-8 136 ± 0% 135 ± 0% -0.74% (p=0.000 n=10+10) So it makes no sense. Refs. #1319.
This commit is contained in:
parent
a1d96a7d7d
commit
4803cc15c7
1 changed files with 9 additions and 0 deletions
|
@ -237,3 +237,12 @@ func BenchmarkPublicUncompressedBytes(t *testing.B) {
|
|||
_ = k.Bytes()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkPublicDecodeBytes(t *testing.B) {
|
||||
keyBytes, err := hex.DecodeString("03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c")
|
||||
require.NoError(t, err)
|
||||
k := new(PublicKey)
|
||||
for n := 0; n < t.N; n++ {
|
||||
require.NoError(t, k.DecodeBytes(keyBytes))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue