forked from mtusi2026/mtusi2026lab7
20 lines
392 B
Go
20 lines
392 B
Go
package services
|
|
|
|
import "testing"
|
|
|
|
func BenchmarkPasswordVerification(b *testing.B) {
|
|
const password = "synthetic-benchmark-password"
|
|
hash, err := HashPassword(password)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
ok, err := VerifyPassword(password, hash)
|
|
if err != nil || !ok {
|
|
b.Fatalf("verification failed: %v", err)
|
|
}
|
|
}
|
|
}
|