crypto: using testing.B.Loop

Signed-off-by: yajianggroup <yajianggroup@outlook.com>
This commit is contained in:
yajianggroup 2025-09-23 15:50:07 +08:00
parent 2872242045
commit 1eb9f9753f
2 changed files with 4 additions and 6 deletions

View file

@ -107,23 +107,21 @@ func TestG2SelfAddition(t *testing.T) {
func BenchmarkG1(b *testing.B) {
x, _ := rand.Int(rand.Reader, Order)
b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
new(G1).ScalarBaseMult(x)
}
}
func BenchmarkG2(b *testing.B) {
x, _ := rand.Int(rand.Reader, Order)
b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
new(G2).ScalarBaseMult(x)
}
}
func BenchmarkPairing(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
Pair(&G1{curveGen}, &G2{twistGen})
}
}

View file

@ -305,7 +305,7 @@ func TestTripartiteDiffieHellman(t *testing.T) {
}
func BenchmarkPairing(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
Pair(&G1{curveGen}, &G2{twistGen})
}
}