libgocryptfs/internal/speed/speed_test.go
Jakob Unterwurzacher b370325ccf speed: GoGCM: start at block size 16
BenchmarkGoGCMBlockSize/16-4      	 5499200	       219.7 ns/op	  72.83 MB/s
BenchmarkGoGCMBlockSize/32-4      	 4497284	       266.2 ns/op	 120.22 MB/s
BenchmarkGoGCMBlockSize/64-4      	 3296336	       363.4 ns/op	 176.10 MB/s
BenchmarkGoGCMBlockSize/128-4     	 4204794	       285.5 ns/op	 448.36 MB/s
BenchmarkGoGCMBlockSize/256-4     	 2928472	       409.7 ns/op	 624.83 MB/s
BenchmarkGoGCMBlockSize/512-4     	 1825164	       658.0 ns/op	 778.09 MB/s
BenchmarkGoGCMBlockSize/1024-4    	 1000000	      1151 ns/op	 889.98 MB/s
BenchmarkGoGCMBlockSize/2048-4    	  560275	      2135 ns/op	 959.47 MB/s
BenchmarkGoGCMBlockSize/4096-4    	  291906	      4099 ns/op	 999.28 MB/s
BenchmarkGoGCMBlockSize/8192-4    	  148916	      8033 ns/op	1019.83 MB/s
BenchmarkGoGCMBlockSize/16384-4   	   75337	     15911 ns/op	1029.75 MB/s
BenchmarkGoGCMBlockSize/32768-4   	   37912	     31651 ns/op	1035.30 MB/s
BenchmarkGoGCMBlockSize/65536-4   	   19000	     64287 ns/op	1019.43 MB/s
BenchmarkGoGCMBlockSize/131072-4  	    9225	    127636 ns/op	1026.92 MB/s
BenchmarkGoGCMBlockSize/262144-4  	    4752	    252300 ns/op	1039.02 MB/s
BenchmarkGoGCMBlockSize/524288-4  	    2377	    504612 ns/op	1038.99 MB/s
BenchmarkGoGCMBlockSize/1048576-4 	    1183	   1011637 ns/op	1036.51 MB/s
2023-03-08 17:04:07 +01:00

93 lines
2.0 KiB
Go

package speed
import (
"crypto/aes"
"crypto/cipher"
"fmt"
"testing"
"golang.org/x/crypto/chacha20poly1305"
"github.com/rfjakob/gocryptfs/v2/internal/siv_aead"
"github.com/rfjakob/gocryptfs/v2/internal/stupidgcm"
)
/*
Make the "-speed" benchmarks also accessible to the standard test system.
Example run:
$ go test -bench .
BenchmarkStupidGCM-2 100000 22552 ns/op 181.62 MB/s
BenchmarkGoGCM-2 20000 81871 ns/op 50.03 MB/s
BenchmarkAESSIV-2 10000 104623 ns/op 39.15 MB/s
PASS
ok github.com/rfjakob/gocryptfs/v2/internal/speed 6.022s
*/
func BenchmarkStupidGCM(b *testing.B) {
bStupidGCM(b)
}
func BenchmarkStupidGCMDecrypt(b *testing.B) {
if stupidgcm.BuiltWithoutOpenssl {
b.Skip("openssl has been disabled at compile-time")
}
bDecrypt(b, stupidgcm.NewAES256GCM(randBytes(32)))
}
func BenchmarkGoGCM(b *testing.B) {
bGoGCM(b)
}
func BenchmarkGoGCMBlockSize(b *testing.B) {
for blockSize := 16; blockSize <= 1024*1024; blockSize *= 2 {
name := fmt.Sprintf("%d", blockSize)
b.Run(name, func(b *testing.B) { bGoGCMBlockSize(b, blockSize) })
}
}
func BenchmarkGoGCMDecrypt(b *testing.B) {
gAES, err := aes.NewCipher(randBytes(32))
if err != nil {
b.Fatal(err)
}
gGCM, err := cipher.NewGCMWithNonceSize(gAES, 16)
if err != nil {
b.Fatal(err)
}
bDecrypt(b, gGCM)
}
func BenchmarkAESSIV(b *testing.B) {
bAESSIV(b)
}
func BenchmarkAESSIVDecrypt(b *testing.B) {
bEncrypt(b, siv_aead.New(randBytes(64)))
}
func BenchmarkXchacha(b *testing.B) {
bXchacha20poly1305(b)
}
func BenchmarkXchachaDecrypt(b *testing.B) {
c, _ := chacha20poly1305.NewX(randBytes(32))
bDecrypt(b, c)
}
func BenchmarkStupidXchacha(b *testing.B) {
bStupidXchacha(b)
}
func BenchmarkStupidXchachaDecrypt(b *testing.B) {
bDecrypt(b, stupidgcm.NewXchacha20poly1305(randBytes(32)))
}
func BenchmarkStupidChacha(b *testing.B) {
bEncrypt(b, stupidgcm.NewChacha20poly1305(randBytes(32)))
}
func BenchmarkStupidChachaDecrypt(b *testing.B) {
bDecrypt(b, stupidgcm.NewChacha20poly1305(randBytes(32)))
}