bcrypt: benchmark defaults
Currently the benchmarks hard code "10" for the cost but maybe a better benchmark would be to use the DefaultCost, since this is the most common use mode for the bcrypt package. Change-Id: Ie89853fcbe4a3a2830fff812ae5cfe908df145fe Reviewed-on: https://go-review.googlesource.com/c/144338 Reviewed-by: Filippo Valsorda <filippo@golang.org>
This commit is contained in:
committed by
Filippo Valsorda
parent
b078efbc80
commit
bc7917b19d
@@ -209,19 +209,19 @@ func TestMinorNotRequired(t *testing.T) {
|
|||||||
func BenchmarkEqual(b *testing.B) {
|
func BenchmarkEqual(b *testing.B) {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
passwd := []byte("somepasswordyoulike")
|
passwd := []byte("somepasswordyoulike")
|
||||||
hash, _ := GenerateFromPassword(passwd, 10)
|
hash, _ := GenerateFromPassword(passwd, DefaultCost)
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
CompareHashAndPassword(hash, passwd)
|
CompareHashAndPassword(hash, passwd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkGeneration(b *testing.B) {
|
func BenchmarkDefaultCost(b *testing.B) {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
passwd := []byte("mylongpassword1234")
|
passwd := []byte("mylongpassword1234")
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
GenerateFromPassword(passwd, 10)
|
GenerateFromPassword(passwd, DefaultCost)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user