Skip to content

Commit

Permalink
reset timer before entering the crypto benchmark loop
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Sep 25, 2018
1 parent af046a3 commit c68823d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,18 @@ func BenchmarkSalsa20(b *testing.B) {
}

func benchCrypt(b *testing.B, bc BlockCrypt) {
b.ReportAllocs()
data := make([]byte, mtuLimit)
io.ReadFull(rand.Reader, data)
dec := make([]byte, mtuLimit)
enc := make([]byte, mtuLimit)

b.ReportAllocs()
b.SetBytes(int64(len(enc) * 2))
b.ResetTimer()
for i := 0; i < b.N; i++ {
bc.Encrypt(enc, data)
bc.Decrypt(dec, enc)
}
b.SetBytes(int64(len(enc) * 2))
}

func BenchmarkCRC32(b *testing.B) {
Expand Down

0 comments on commit c68823d

Please sign in to comment.