Skip to content

Commit

Permalink
add bench
Browse files Browse the repository at this point in the history
  • Loading branch information
Liuhaai committed Apr 10, 2024
1 parent 8498bf1 commit f9da1c0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crypto/secp256k1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,19 @@ func TestSecp256k1(t *testing.T) {
require.Equal("53fbc28faf9a52dfe5f591948a23189e900381b5", hex.EncodeToString(pk.Hash()))

}

func BenchmarkSecp256k1(b *testing.B) {
require := require.New(b)

sk, err := newSecp256k1PrvKey()
require.NoError(err)
defer sk.Zero()
pk := sk.PublicKey()
require.Equal(secp256pubKeyLength, len(pk.Bytes()))
b.ResetTimer()
pkData := pk.Bytes()
for n := 0; n < b.N; n++ {
_, err := newSecp256k1PubKeyFromBytes(pkData)
require.NoError(err)
}
}

0 comments on commit f9da1c0

Please sign in to comment.