From e5be84162206a3f60b92a5a0f28174e2c78a477e Mon Sep 17 00:00:00 2001 From: mihir Date: Mon, 9 Sep 2024 15:47:29 +0530 Subject: [PATCH] updated benchmark test --- encrypt/benchmark_test.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/encrypt/benchmark_test.go b/encrypt/benchmark_test.go index 84d568b0..2edd80a5 100644 --- a/encrypt/benchmark_test.go +++ b/encrypt/benchmark_test.go @@ -22,16 +22,23 @@ BenchmarkEncryptDecrypt/AESGCM_AES256-12 687800 1720 ns/op */ func BenchmarkEncryptDecrypt(b *testing.B) { tests := []struct { - name string - algo EncryptionAlgorithm - level EncryptionLevel + payload []byte + name string + algo EncryptionAlgorithm + level EncryptionLevel }{ - {"AESCFB_AES128", EncryptionAlgoAESCFB, EncryptionLevelAES128}, - {"AESCFB_AES192", EncryptionAlgoAESCFB, EncryptionLevelAES192}, - {"AESCFB_AES256", EncryptionAlgoAESCFB, EncryptionLevelAES256}, - {"AESGCM_AES128", EncryptionAlgoAESGCM, EncryptionLevelAES128}, - {"AESGCM_AES192", EncryptionAlgoAESGCM, EncryptionLevelAES192}, - {"AESGCM_AES256", EncryptionAlgoAESGCM, EncryptionLevelAES256}, + {[]byte("small payload"), "SMALL_AESCFB_AES128", EncryptionAlgoAESCFB, EncryptionLevelAES128}, + {[]byte("small payload"), "SMALL_AESCFB_AES192", EncryptionAlgoAESCFB, EncryptionLevelAES192}, + {[]byte("small payload"), "SMALL_AESCFB_AES256", EncryptionAlgoAESCFB, EncryptionLevelAES256}, + {[]byte("small payload"), "SMALL_AESGCM_AES128", EncryptionAlgoAESGCM, EncryptionLevelAES128}, + {[]byte("small payload"), "SMALL_AESGCM_AES192", EncryptionAlgoAESGCM, EncryptionLevelAES192}, + {[]byte("small payload"), "SMALL_AESGCM_AES256", EncryptionAlgoAESGCM, EncryptionLevelAES256}, + {make([]byte, 2*1024*1024), "LARGE_AESCFB_AES128", EncryptionAlgoAESCFB, EncryptionLevelAES128}, + {make([]byte, 2*1024*1024), "LARGE_AESCFB_AES192", EncryptionAlgoAESCFB, EncryptionLevelAES192}, + {make([]byte, 2*1024*1024), "LARGE_AESCFB_AES256", EncryptionAlgoAESCFB, EncryptionLevelAES256}, + {make([]byte, 2*1024*1024), "LARGE_AESGCM_AES128", EncryptionAlgoAESGCM, EncryptionLevelAES128}, + {make([]byte, 2*1024*1024), "LARGE_AESGCM_AES192", EncryptionAlgoAESGCM, EncryptionLevelAES192}, + {make([]byte, 2*1024*1024), "LARGE_AESGCM_AES256", EncryptionAlgoAESGCM, EncryptionLevelAES256}, } for _, tt := range tests { @@ -43,7 +50,7 @@ func BenchmarkEncryptDecrypt(b *testing.B) { key, err := generateRandomString(int(tt.level / 8)) require.NoError(b, err) - plaintext := loremIpsumDolor + plaintext := tt.payload b.ResetTimer() for i := 0; i < b.N; i++ {