add parallel test

This commit is contained in:
Sun Yimin 2022-09-16 11:48:28 +08:00 committed by GitHub
parent 0946644542
commit 49f25af421
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -363,6 +363,22 @@ func BenchmarkSign_SM2(b *testing.B) {
}
}
func BenchmarkSign_SM2Specific(b *testing.B) {
priv, err := GenerateKey(rand.Reader)
if err != nil {
b.Fatal(err)
}
hashed := []byte("testingtestingtestingtestingtestingtestingtestingtestingtestingtestingtestingtestingtestingtestingtestingtestingtestingtestingtestingtesting")
b.RunParallel(func(p *testing.PB) {
for p.Next() {
_, err := priv.SignWithSM2(rand.Reader, nil, hashed)
if err != nil {
b.Fatal(err)
}
}
})
}
func BenchmarkSign_P256(b *testing.B) {
priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {