MCPcopy Create free account
hub / github.com/apple/foundationdb / bench_decrypt

Function bench_decrypt

flowbench/BenchEncrypt.cpp:58–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58static void bench_decrypt(benchmark::State& state) {
59 auto bytes = state.range(0);
60 auto chunks = state.range(1);
61 auto chunkSize = bytes / chunks;
62 StreamCipherKey::initializeGlobalRandomTestKey();
63 auto key = StreamCipherKey::getGlobalCipherKey();
64 auto iv = getRandomIV();
65 auto data = getKey(bytes);
66 auto encrypted = encrypt(key, iv, data.begin(), data.size());
67 while (state.KeepRunning()) {
68 Arena arena;
69 DecryptionStreamCipher decryptor(key, iv);
70 for (int chunk = 0; chunk < chunks; ++chunk) {
71 benchmark::DoNotOptimize(
72 Standalone<StringRef>(decryptor.decrypt(encrypted.begin() + chunk * chunkSize, chunkSize, arena)));
73 }
74 }
75 state.SetBytesProcessed(bytes * static_cast<long>(state.iterations()));
76}
77
78BENCHMARK(bench_encrypt)->Ranges({ { 1 << 12, 1 << 20 }, { 1, 1 << 12 } });
79BENCHMARK(bench_decrypt)->Ranges({ { 1 << 12, 1 << 20 }, { 1, 1 << 12 } });

Callers

nothing calls this directly

Calls 7

getRandomIVFunction · 0.85
encryptFunction · 0.85
getKeyFunction · 0.70
rangeMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
decryptMethod · 0.45

Tested by

no test coverage detected