| 40 | } |
| 41 | |
| 42 | static void bench_encrypt(benchmark::State& state) { |
| 43 | auto bytes = state.range(0); |
| 44 | auto chunks = state.range(1); |
| 45 | auto chunkSize = bytes / chunks; |
| 46 | StreamCipherKey::initializeGlobalRandomTestKey(); |
| 47 | auto key = StreamCipherKey::getGlobalCipherKey(); |
| 48 | auto iv = getRandomIV(); |
| 49 | auto data = getKey(bytes); |
| 50 | while (state.KeepRunning()) { |
| 51 | for (int chunk = 0; chunk < chunks; ++chunk) { |
| 52 | benchmark::DoNotOptimize(encrypt(key, iv, data.begin() + chunk * chunkSize, chunkSize)); |
| 53 | } |
| 54 | } |
| 55 | state.SetBytesProcessed(bytes * static_cast<long>(state.iterations())); |
| 56 | } |
| 57 | |
| 58 | static void bench_decrypt(benchmark::State& state) { |
| 59 | auto bytes = state.range(0); |
nothing calls this directly
no test coverage detected