Skip to content

Commit bc7917b

Browse files
kevinburkeFiloSottile
authored andcommitted
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>
1 parent b078efb commit bc7917b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bcrypt/bcrypt_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,19 @@ func TestMinorNotRequired(t *testing.T) {
209209
func BenchmarkEqual(b *testing.B) {
210210
b.StopTimer()
211211
passwd := []byte("somepasswordyoulike")
212-
hash, _ := GenerateFromPassword(passwd, 10)
212+
hash, _ := GenerateFromPassword(passwd, DefaultCost)
213213
b.StartTimer()
214214
for i := 0; i < b.N; i++ {
215215
CompareHashAndPassword(hash, passwd)
216216
}
217217
}
218218

219-
func BenchmarkGeneration(b *testing.B) {
219+
func BenchmarkDefaultCost(b *testing.B) {
220220
b.StopTimer()
221221
passwd := []byte("mylongpassword1234")
222222
b.StartTimer()
223223
for i := 0; i < b.N; i++ {
224-
GenerateFromPassword(passwd, 10)
224+
GenerateFromPassword(passwd, DefaultCost)
225225
}
226226
}
227227

0 commit comments

Comments
 (0)