btcec: benchmark ParsePubKey for compressed keys
This commit is contained in:
parent
962a206e94
commit
4aeb189fc4
1 changed files with 23 additions and 1 deletions
|
@ -4,7 +4,10 @@
|
|||
|
||||
package btcec
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// BenchmarkAddJacobian benchmarks the secp256k1 curve addJacobian function with
|
||||
// Z values of 1 so that the associated optimizations are used.
|
||||
|
@ -121,3 +124,22 @@ func BenchmarkFieldNormalize(b *testing.B) {
|
|||
f.Normalize()
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkParseCompressedPubKey benchmarks how long it takes to decompress and
|
||||
// validate a compressed public key from a byte array.
|
||||
func BenchmarkParseCompressedPubKey(b *testing.B) {
|
||||
rawPk, _ := hex.DecodeString("0234f9460f0e4f08393d192b3c5133a6ba099aa0ad9fd54ebccfacdfa239ff49c6")
|
||||
|
||||
var (
|
||||
pk *PublicKey
|
||||
err error
|
||||
)
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
pk, err = ParsePubKey(rawPk, S256())
|
||||
}
|
||||
_ = pk
|
||||
_ = err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue