MCPcopy
hub / github.com/kopia/kopia / BenchmarkEncryption

Function BenchmarkEncryption

repo/encryption/encryption_test.go:173–196  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

171}
172
173func BenchmarkEncryption(b *testing.B) {
174 masterKey := make([]byte, 32)
175 rand.Read(masterKey)
176
177 enc, err := encryption.CreateEncryptor(parameters{encryption.DefaultAlgorithm, masterKey})
178 require.NoError(b, err)
179
180 // 8 MiB
181 plainText := gather.FromSlice(bytes.Repeat([]byte{1, 2, 3, 4, 5, 6, 7, 8}, 1<<20))
182
183 var warmupOut gather.WriteBuffer
184
185 iv := []byte{0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7}
186
187 require.NoError(b, enc.Encrypt(plainText, iv, &warmupOut))
188 warmupOut.Close()
189
190 for b.Loop() {
191 var out gather.WriteBuffer
192
193 enc.Encrypt(plainText, iv, &out)
194 out.Close()
195 }
196}

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
CreateEncryptorFunction · 0.92
FromSliceFunction · 0.92
RepeatMethod · 0.80
EncryptMethod · 0.65
ReadMethod · 0.45

Tested by

no test coverage detected