]> Cypherpunks repositories - gostls13.git/commitdiff
crypto/cipher: add small CTR benchmark, remove CFB/OFB benchmarks
authorFilippo Valsorda <filippo@golang.org>
Sat, 26 Oct 2024 17:45:41 +0000 (19:45 +0200)
committerFilippo Valsorda <filippo@golang.org>
Mon, 18 Nov 2024 16:41:17 +0000 (16:41 +0000)
CFB and OFB are mostly unused, and not a performance target.

Updates #39365
Updates #69445

Change-Id: Ice6441e4fee2112a9e72607c63e49dbc50441ba6
Reviewed-on: https://go-review.googlesource.com/c/go/+/621957
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
src/crypto/cipher/benchmark_test.go

index eb02cd08c50deb39c6b0010ff12c6016a66943db..181d08c9b1469952a5e780ef665f092e0cc09456 100644 (file)
@@ -86,28 +86,16 @@ func benchmarkAESStream(b *testing.B, mode func(cipher.Block, []byte) cipher.Str
 const almost1K = 1024 - 5
 const almost8K = 8*1024 - 5
 
-func BenchmarkAESCFBEncrypt1K(b *testing.B) {
-       benchmarkAESStream(b, cipher.NewCFBEncrypter, make([]byte, almost1K))
-}
-
-func BenchmarkAESCFBDecrypt1K(b *testing.B) {
-       benchmarkAESStream(b, cipher.NewCFBDecrypter, make([]byte, almost1K))
-}
-
-func BenchmarkAESCFBDecrypt8K(b *testing.B) {
-       benchmarkAESStream(b, cipher.NewCFBDecrypter, make([]byte, almost8K))
-}
-
-func BenchmarkAESOFB1K(b *testing.B) {
-       benchmarkAESStream(b, cipher.NewOFB, make([]byte, almost1K))
-}
-
-func BenchmarkAESCTR1K(b *testing.B) {
-       benchmarkAESStream(b, cipher.NewCTR, make([]byte, almost1K))
-}
-
-func BenchmarkAESCTR8K(b *testing.B) {
-       benchmarkAESStream(b, cipher.NewCTR, make([]byte, almost8K))
+func BenchmarkAESCTR(b *testing.B) {
+       b.Run("50", func(b *testing.B) {
+               benchmarkAESStream(b, cipher.NewCTR, make([]byte, 50))
+       })
+       b.Run("1K", func(b *testing.B) {
+               benchmarkAESStream(b, cipher.NewCTR, make([]byte, almost1K))
+       })
+       b.Run("8K", func(b *testing.B) {
+               benchmarkAESStream(b, cipher.NewCTR, make([]byte, almost8K))
+       })
 }
 
 func BenchmarkAESCBCEncrypt1K(b *testing.B) {